diff --git a/src/Tabs/RadioTab.tsx b/src/Tabs/RadioTab.tsx index 06a2b299..b285b272 100644 --- a/src/Tabs/RadioTab.tsx +++ b/src/Tabs/RadioTab.tsx @@ -2,10 +2,15 @@ import React, { forwardRef, ReactNode } from 'react' import clsx from 'clsx' import { twMerge } from 'tailwind-merge' +import { ComponentColor } from '../types' + export type RadioTabProps = Omit< React.InputHTMLAttributes, - 'type' + 'type' | 'color' > & { + color?: ComponentColor + bgColor?: string + borderColor?: string active?: boolean disabled?: boolean label: string @@ -18,6 +23,9 @@ const RadioTab = forwardRef( { children, className, + color, + bgColor, + borderColor, active, label, disabled, @@ -31,6 +39,16 @@ const RadioTab = forwardRef( 'tab', className, clsx({ + [`[--tab-bg:${bgColor}]`]: bgColor, + [`[--tab-border-color:${borderColor}]`]: borderColor, + 'text-neutral': color === 'neutral', + 'text-primary': color === 'primary', + 'text-secondary': color === 'secondary', + 'text-accent': color === 'accent', + 'text-info': color === 'info', + 'text-success': color === 'success', + 'text-warning': color === 'warning', + 'text-error': color === 'error', 'tab-active': active, 'tab-disabled': disabled, }) diff --git a/src/Tabs/Tab.tsx b/src/Tabs/Tab.tsx index 6646f864..e6c3c5c8 100644 --- a/src/Tabs/Tab.tsx +++ b/src/Tabs/Tab.tsx @@ -2,17 +2,41 @@ import React, { forwardRef } from 'react' import clsx from 'clsx' import { twMerge } from 'tailwind-merge' -export type TabProps = React.AnchorHTMLAttributes & { +import { ComponentColor } from '../types' + +export type TabProps = Omit, 'color'> & { + color?: ComponentColor + bgColor?: string + borderColor?: string active?: boolean disabled?: boolean } const Tab = forwardRef( - ({ children, className, active, disabled, ...props }, ref): JSX.Element => { + ({ + children, + className, + color, + bgColor, + borderColor, + active, + disabled, + ...props + }, ref): JSX.Element => { const classes = twMerge( 'tab', className, clsx({ + [`[--tab-bg:${bgColor}]`]: bgColor, + [`[--tab-border-color:${borderColor}]`]: borderColor, + 'text-neutral': color === 'neutral', + 'text-primary': color === 'primary', + 'text-secondary': color === 'secondary', + 'text-accent': color === 'accent', + 'text-info': color === 'info', + 'text-success': color === 'success', + 'text-warning': color === 'warning', + 'text-error': color === 'error', 'tab-active': active, 'tab-disabled': disabled, }) diff --git a/src/Tabs/Tabs.stories.tsx b/src/Tabs/Tabs.stories.tsx index 1e05bc4e..43034540 100644 --- a/src/Tabs/Tabs.stories.tsx +++ b/src/Tabs/Tabs.stories.tsx @@ -132,3 +132,18 @@ RadioTabLifted.args = { className: 'w-full my-10 lg:mx-10', variant: 'lifted', } + +export const TabsWithCustomColor: Story = (args) => { + return ( + + Tab 1 + Tab 2 + Tab 3 + + ) +} +TabsWithCustomColor.args = { + className: 'w-full my-10 lg:mx-10', + variant: 'lifted', +} + diff --git a/src/Tabs/Tabs.tsx b/src/Tabs/Tabs.tsx index 1bcaffb5..62c6bcb1 100644 --- a/src/Tabs/Tabs.tsx +++ b/src/Tabs/Tabs.tsx @@ -1,4 +1,4 @@ -import React, { cloneElement, forwardRef, ReactElement } from 'react' +import React, { forwardRef } from 'react' import clsx from 'clsx' import { twMerge } from 'tailwind-merge'