File tree Expand file tree Collapse file tree
packages/ui-components/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ type Props = {
1515 onChange ?: ( value : string ) => void ;
1616 disabled ?: boolean ;
1717 className ?: string ;
18+ variant ?: 'default' | 'pill' ;
1819} ;
1920
2021const ToggleSwitch = ( {
@@ -23,6 +24,7 @@ const ToggleSwitch = ({
2324 onChange,
2425 disabled,
2526 className,
27+ variant = 'default' ,
2628} : Props ) => {
2729 const [ selectedValue , setSelectedValue ] = useState < string > (
2830 defaultValue ?? options [ 0 ] . value ,
@@ -42,7 +44,12 @@ const ToggleSwitch = ({
4244 value = { selectedValue }
4345 onValueChange = { handleValueChange }
4446 className = { cn (
45- 'inline-flex bg-background border rounded-[4px] p-[1px] gap-[2px]' ,
47+ 'inline-flex border gap-[2px]' ,
48+ {
49+ 'bg-gray-100 dark:bg-gray-900 rounded-[40px] py-[6px] px-[8px] h-[54px]' :
50+ variant === 'pill' ,
51+ 'bg-background rounded-[4px] p-[1px]' : variant !== 'pill' ,
52+ } ,
4653 className ,
4754 ) }
4855 variant = "outline"
@@ -57,12 +64,12 @@ const ToggleSwitch = ({
5764 < ToggleGroupItem
5865 value = { option . value }
5966 size = "xs"
60- className = { cn (
61- 'w-[66px] px-2 py-1' ,
62- 'rounded text-sm font-normal transition-colors aria-checked:bg-gray-200 dark:aria-checked:bg-gray-800 ',
63- 'border-0' ,
64- 'rounded-[4px] ',
65- ) }
67+ className = { cn ( 'text-sm transition-colors border-0' , {
68+ 'px-5 h-[42px] rounded-[40px] font-medium aria-checked:bg-primary-200 aria-checked:text-background' :
69+ variant === 'pill ',
70+ 'w-[66px] px-2 py-1 rounded-[4px] font-normal aria-checked:bg-gray-200 dark:aria-checked:bg-gray-800' :
71+ variant !== 'pill ',
72+ } ) }
6673 >
6774 { option . label }
6875 </ ToggleGroupItem >
Original file line number Diff line number Diff line change @@ -87,4 +87,21 @@ export const Disabled: Story = {
8787 } ,
8888} ;
8989
90+ export const Pill : Story = {
91+ args : {
92+ options,
93+ variant : 'pill' ,
94+ onChange : action ( 'onChange' ) ,
95+ } ,
96+ } ;
97+
98+ export const PillDisabled : Story = {
99+ args : {
100+ options,
101+ variant : 'pill' ,
102+ disabled : true ,
103+ onChange : action ( 'onChange' ) ,
104+ } ,
105+ } ;
106+
90107export default meta ;
You can’t perform that action at this time.
0 commit comments