@@ -72,7 +72,7 @@
>
{@const TypeDef = typeDef}
diff --git a/sites/docs/src/lib/components/api-section.svelte b/sites/docs/src/lib/components/api-section.svelte
index 50c1c9e35..2893c61d0 100644
--- a/sites/docs/src/lib/components/api-section.svelte
+++ b/sites/docs/src/lib/components/api-section.svelte
@@ -19,7 +19,7 @@
class="inline-flex h-[29px] items-center justify-center rounded-button bg-accent px-3 font-mono text-[17px] font-medium leading-tight tracking-tight dark:text-neutral-900"
>
- {$page.data.title.replaceAll(" ", "")}.{schema.title}
diff --git a/sites/docs/src/lib/components/demos/index.ts b/sites/docs/src/lib/components/demos/index.ts
index 37ff648ac..6a059e362 100644
--- a/sites/docs/src/lib/components/demos/index.ts
+++ b/sites/docs/src/lib/components/demos/index.ts
@@ -47,6 +47,7 @@ export { default as ScrollAreaDemo } from "./scroll-area-demo.svelte";
export { default as ScrollAreaDemoCustom } from "./scroll-area-demo-custom.svelte";
export { default as SeparatorDemo } from "./separator-demo.svelte";
export { default as SliderDemo } from "./slider-demo.svelte";
+export { default as SliderDemoMultiple } from "./slider-demo-multiple.svelte";
export { default as SwitchDemo } from "./switch-demo.svelte";
export { default as SwitchDemoCustom } from "./switch-demo-custom.svelte";
export { default as TabsDemo } from "./tabs-demo.svelte";
diff --git a/sites/docs/src/lib/components/demos/slider-demo-multiple.svelte b/sites/docs/src/lib/components/demos/slider-demo-multiple.svelte
new file mode 100644
index 000000000..fa2ceecd7
--- /dev/null
+++ b/sites/docs/src/lib/components/demos/slider-demo-multiple.svelte
@@ -0,0 +1,30 @@
+
+
+
+
+ {#snippet children({ thumbs })}
+
+
+
+ {#each thumbs as index}
+
+ {/each}
+ {/snippet}
+
+
diff --git a/sites/docs/src/lib/components/demos/slider-demo.svelte b/sites/docs/src/lib/components/demos/slider-demo.svelte
index ee6a02883..56cd3e599 100644
--- a/sites/docs/src/lib/components/demos/slider-demo.svelte
+++ b/sites/docs/src/lib/components/demos/slider-demo.svelte
@@ -2,23 +2,27 @@
import { Slider } from "bits-ui";
import { cn } from "$lib/utils/styles.js";
- let value = [50];
+ let value = $state(50);
-
- {#snippet children({ thumbs })}
-
+
+ {#snippet children()}
+
- {#each thumbs as index}
-
- {/each}
+
{/snippet}
diff --git a/sites/docs/src/lib/content/api-reference/extended-types/slider/slider-root-on-value-change.md b/sites/docs/src/lib/content/api-reference/extended-types/slider/slider-root-on-value-change.md
index a404482b1..8ad2c4fe0 100644
--- a/sites/docs/src/lib/content/api-reference/extended-types/slider/slider-root-on-value-change.md
+++ b/sites/docs/src/lib/content/api-reference/extended-types/slider/slider-root-on-value-change.md
@@ -1,3 +1,6 @@
```ts
+// type="single"
+(value: number) => void
+// type="multiple"
(value: number[]) => void
```
diff --git a/sites/docs/src/lib/content/api-reference/helpers.ts b/sites/docs/src/lib/content/api-reference/helpers.ts
index cb52386b2..508c84bf4 100644
--- a/sites/docs/src/lib/content/api-reference/helpers.ts
+++ b/sites/docs/src/lib/content/api-reference/helpers.ts
@@ -543,7 +543,7 @@ export const dirProp = createEnumProp({
definition: DirProp,
options: ["ltr", "rtl"],
description: "The reading direction of the app.",
- default: "ltr",
+ default: "'ltr'",
});
export const orientationDataAttr = createEnumDataAttr({
diff --git a/sites/docs/src/lib/content/api-reference/slider.api.ts b/sites/docs/src/lib/content/api-reference/slider.api.ts
index 41a7f3d2a..3e9b69a2c 100644
--- a/sites/docs/src/lib/content/api-reference/slider.api.ts
+++ b/sites/docs/src/lib/content/api-reference/slider.api.ts
@@ -5,7 +5,7 @@ import type {
SliderTickPropsWithoutHTML,
} from "bits-ui";
import { SliderRootOnValueChangeProp } from "./extended-types/slider/index.js";
-import { OrientationProp } from "./extended-types/shared/index.js";
+import { OrientationProp, SingleOrMultipleProp } from "./extended-types/shared/index.js";
import {
controlledValueProp,
createApiSchema,
@@ -14,6 +14,7 @@ import {
createEnumProp,
createFunctionProp,
createNumberProp,
+ createUnionProp,
dirProp,
withChildProps,
} from "$lib/content/api-reference/helpers.js";
@@ -23,10 +24,18 @@ const root = createApiSchema({
title: "Root",
description: "The root slider component which contains the remaining slider components.",
props: {
+ type: createUnionProp({
+ options: ["'single'", "'multiple'"],
+ description:
+ "The type of the slider. If set to `'multiple'`, the slider will allow multiple thumbs and the `value` will be an array of numbers.",
+ required: true,
+ definition: SingleOrMultipleProp,
+ }),
value: {
- default: "[]",
- type: "number[]",
- description: "The current value of the slider.",
+ default: "0",
+ type: "number",
+ description:
+ "The current value of the slider. If the `type` is set to `'multiple'`, this should be an array of numbers and will default to an empty array.",
bindable: true,
},
onValueChange: createFunctionProp({
@@ -53,7 +62,7 @@ const root = createApiSchema({
}),
orientation: createEnumProp({
options: ["horizontal", "vertical"],
- default: '"horizontal"',
+ default: "'horizontal'",
description: "The orientation of the slider.",
definition: OrientationProp,
}),
@@ -65,7 +74,7 @@ const root = createApiSchema({
autoSort: createBooleanProp({
default: C.TRUE,
description:
- "Whether to automatically sort the values in the array when moving thumbs past one another.",
+ "Whether to automatically sort the values in the array when moving thumbs past one another. This is only applicable to the `'multiple'` type.",
}),
...withChildProps({ elType: "HTMLSpanElement" }),
},
diff --git a/sites/docs/src/routes/(main)/sink/+page.svelte b/sites/docs/src/routes/(main)/sink/+page.svelte
index f4f3a4de1..a80edf4b0 100644
--- a/sites/docs/src/routes/(main)/sink/+page.svelte
+++ b/sites/docs/src/routes/(main)/sink/+page.svelte
@@ -31,7 +31,7 @@
-
+
{#snippet children({ thumbs })}