@datawire-ai/busyfile-design-library 1.25.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -17
- package/dist/index.js +2580 -2403
- package/dist/index.umd.cjs +35 -45
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -327,30 +327,45 @@ A customizable and accessible `toggle button` (switch) component. Supports both
|
|
|
327
327
|
## Usage
|
|
328
328
|
|
|
329
329
|
```tsx
|
|
330
|
-
|
|
331
330
|
// Controlled toggle
|
|
332
|
-
|
|
331
|
+
'use client';
|
|
333
332
|
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
import * as React from 'react';
|
|
334
|
+
import { Toggle } from '@/components/ui/toggle-button';
|
|
336
335
|
|
|
337
|
-
|
|
338
|
-
|
|
336
|
+
export default function Example() {
|
|
337
|
+
const [checked, setChecked] = React.useState(false);
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<div className="flex items-center gap-3">
|
|
341
|
+
<Toggle
|
|
342
|
+
id="dark-mode"
|
|
343
|
+
checked={checked}
|
|
344
|
+
onCheckedChange={setChecked}
|
|
345
|
+
className="data-[state=checked]:bg-green-500 data-[state=unchecked]:bg-gray-300"
|
|
346
|
+
/>
|
|
347
|
+
<label
|
|
348
|
+
htmlFor="dark-mode"
|
|
349
|
+
className="cursor-pointer select-none text-sm font-medium"
|
|
350
|
+
>
|
|
351
|
+
Enable Dark Mode
|
|
352
|
+
</label>
|
|
353
|
+
</div>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
339
356
|
```
|
|
340
357
|
|
|
341
358
|
### Props
|
|
342
359
|
|
|
343
|
-
| Prop | Type
|
|
344
|
-
| ----------------- |
|
|
345
|
-
| `checked` | `boolean`
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `disabled` | `boolean`
|
|
349
|
-
| `
|
|
350
|
-
| `
|
|
351
|
-
| `
|
|
352
|
-
| `aria-label` | `string` | `-` | Accessible label (required if no visible label is present). |
|
|
353
|
-
| `aria-labelledby` | `string` | `-` | ID of an element labeling the toggle. |
|
|
360
|
+
| Prop | Type | Default | Description |
|
|
361
|
+
| ----------------- | --------------------------------------------------- | ------- | --------------------------------------------------------------- |
|
|
362
|
+
| `checked` | `boolean` | `false` | Controls the switch state (on/off). |
|
|
363
|
+
| `defaultChecked` | `boolean` | `false` | Sets the initial state when using the switch uncontrolled. |
|
|
364
|
+
| `onCheckedChange` | `(checked: boolean) => void` | `—` | Callback function fired when the checked state changes. |
|
|
365
|
+
| `disabled` | `boolean` | `false` | Disables the switch if `true`. |
|
|
366
|
+
| `id` | `string` | `—` | Used to pair the switch with a `<label>` for accessibility. |
|
|
367
|
+
| `className` | `string` | `—` | Apply custom Tailwind/utility classes. |
|
|
368
|
+
| `...props` | `React.ComponentProps<typeof SwitchPrimitive.Root>` | `—` | Any additional props supported by Radix `SwitchPrimitive.Root`. |
|
|
354
369
|
|
|
355
370
|
# Radio Button
|
|
356
371
|
|