diff --git a/docs/components/content/examples/TabsExampleBasic.vue b/docs/components/content/examples/TabsExampleBasic.vue new file mode 100644 index 0000000000..6d3a1c2b30 --- /dev/null +++ b/docs/components/content/examples/TabsExampleBasic.vue @@ -0,0 +1,17 @@ + + + diff --git a/docs/components/content/examples/TabsExampleCard.vue b/docs/components/content/examples/TabsExampleCard.vue new file mode 100644 index 0000000000..6d3a1c2b30 --- /dev/null +++ b/docs/components/content/examples/TabsExampleCard.vue @@ -0,0 +1,17 @@ + + + diff --git a/docs/components/content/examples/TabsExampleDefaultSlot.vue b/docs/components/content/examples/TabsExampleDefaultSlot.vue new file mode 100644 index 0000000000..1e12b16cc4 --- /dev/null +++ b/docs/components/content/examples/TabsExampleDefaultSlot.vue @@ -0,0 +1,29 @@ + + + diff --git a/docs/components/content/examples/TabsExampleIndex.vue b/docs/components/content/examples/TabsExampleIndex.vue new file mode 100644 index 0000000000..4ab9951118 --- /dev/null +++ b/docs/components/content/examples/TabsExampleIndex.vue @@ -0,0 +1,16 @@ + + + diff --git a/docs/components/content/examples/TabsExampleItemCustomSlot.vue b/docs/components/content/examples/TabsExampleItemCustomSlot.vue new file mode 100644 index 0000000000..ef8143fab5 --- /dev/null +++ b/docs/components/content/examples/TabsExampleItemCustomSlot.vue @@ -0,0 +1,76 @@ + + + diff --git a/docs/components/content/examples/TabsExampleItemSlot.vue b/docs/components/content/examples/TabsExampleItemSlot.vue new file mode 100644 index 0000000000..20141c1d51 --- /dev/null +++ b/docs/components/content/examples/TabsExampleItemSlot.vue @@ -0,0 +1,58 @@ + + + diff --git a/docs/components/content/examples/TabsExampleVertical.vue b/docs/components/content/examples/TabsExampleVertical.vue new file mode 100644 index 0000000000..a5f73297c4 --- /dev/null +++ b/docs/components/content/examples/TabsExampleVertical.vue @@ -0,0 +1,16 @@ + + + diff --git a/docs/content/5.navigation/4.tabs.md b/docs/content/5.navigation/4.tabs.md new file mode 100644 index 0000000000..b90d24da2c --- /dev/null +++ b/docs/content/5.navigation/4.tabs.md @@ -0,0 +1,296 @@ +--- +description: A set of tab panels that are displayed one at a time. +links: + - label: GitHub + icon: i-simple-icons-github + to: https://github.com/nuxtlabs/ui/blob/dev/src/runtime/components/navigation/Tabs.vue +navigation: + badge: Edge +--- + +## Usage + +Pass an array to the `items` prop of the Tabs component. Each item can have the following properties: + +- `label` - The label of the item. +- `slot` - A key to customize the item with a slot. +- `content` - The content to display in the panel by default. +- `disabled` - Determines whether the item is disabled or not. + +::component-example +#default +:tabs-example-basic{class="w-full"} + +#code +```vue + + + +``` +:: + +### Vertical + +You can change the orientation of the tabs by setting the `orientation` prop to `vertical`. + +::component-example +#default +:tabs-example-vertical{class="w-full"} + +#code +```vue + + + +``` +:: + +### Default index + +You can set the default index of the tabs by setting the `default-index` prop. + +::component-example +#default +:tabs-example-index{class="w-full"} + +#code +```vue + + + +``` +:: + +## Slots + +You can use slots to customize the buttons and items content of the Accordion. + +### `default` + +Use the `#default` slot to customize the content of the trigger buttons. You will have access to the `item`, `index`, `selected` and `disabled` in the slot scope. + +::component-example +#default +:tabs-example-default-slot + +#code +```vue + + + +``` +:: + +### `item` + +Use the `#item` slot to customize the items content. You will have access to the `item`, `index` and `selected` properties in the slot scope. + +::component-example +#default +:tabs-example-item-slot + +#code +```vue + + + +``` +:: + +You can also pass a `slot` property to customize a specific item. + +::component-example +#default +:tabs-example-item-custom-slot + +#code +```vue + + + +``` +:: + +## Props + +:component-props + +## Preset + +:component-preset diff --git a/src/runtime/app.config.ts b/src/runtime/app.config.ts index 265606bf2a..154a923102 100644 --- a/src/runtime/app.config.ts +++ b/src/runtime/app.config.ts @@ -765,6 +765,40 @@ const pagination = { } } +const tabs = { + wrapper: 'relative space-y-2', + container: 'relative w-full', + base: 'focus:outline-none', + list: { + base: 'relative', + background: 'bg-gray-100 dark:bg-gray-800', + rounded: 'rounded-lg', + shadow: '', + padding: 'p-1', + height: 'h-10', + width: 'w-full', + marker: { + wrapper: 'absolute top-[4px] left-[4px] duration-200 ease-out focus:outline-none', + base: 'w-full h-full', + background: 'bg-white dark:bg-gray-900', + rounded: 'rounded-md', + shadow: 'shadow-sm' + }, + tab: { + base: 'relative inline-flex items-center justify-center flex-shrink-0 w-full whitespace-nowrap focus:outline-none disabled:cursor-not-allowed disabled:opacity-75 transition-colors duration-200 ease-out', + background: '', + active: 'text-gray-900 dark:text-white', + inactive: 'text-gray-500 dark:text-gray-400', + height: 'h-8', + padding: 'px-3', + size: 'text-sm', + font: 'font-medium', + rounded: 'rounded-md', + shadow: '' + } + } +} + // Overlays const modal = { @@ -984,6 +1018,7 @@ export default { verticalNavigation, commandPalette, pagination, + tabs, modal, slideover, popover, diff --git a/src/runtime/components/navigation/Tabs.vue b/src/runtime/components/navigation/Tabs.vue new file mode 100644 index 0000000000..ddcd6b7d11 --- /dev/null +++ b/src/runtime/components/navigation/Tabs.vue @@ -0,0 +1,117 @@ + + + diff --git a/src/runtime/types/index.d.ts b/src/runtime/types/index.d.ts index 17247e97e8..45793444d3 100644 --- a/src/runtime/types/index.d.ts +++ b/src/runtime/types/index.d.ts @@ -6,4 +6,5 @@ export * from './command-palette' export * from './dropdown' export * from './notification' export * from './popper' +export * from './tabs' export * from './vertical-navigation' diff --git a/src/runtime/types/tabs.d.ts b/src/runtime/types/tabs.d.ts new file mode 100644 index 0000000000..e86895a520 --- /dev/null +++ b/src/runtime/types/tabs.d.ts @@ -0,0 +1,6 @@ +export interface TabItem { + label: string + slot?: string + disabled?: boolean + content?: string +}