diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 31be202d5..530e12fd7 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -168,6 +168,8 @@ function sidebar() { text: 'Utilities', collapsed: false, items: [ + { text: 'Config Provider', link: '/utilities/config-provider' }, + { text: 'Visually Hidden', link: '/utilities/visually-hidden' }, { text: 'Primitive', link: '/utilities/primitive' }, { text: 'Slot', link: '/utilities/slot' }, { text: 'useId', link: '/utilities/use-id' }, diff --git a/docs/content/utilities/config-provider.md b/docs/content/utilities/config-provider.md new file mode 100644 index 000000000..d24847ef8 --- /dev/null +++ b/docs/content/utilities/config-provider.md @@ -0,0 +1,83 @@ +--- +title: Config Provider +description: Wraps your app to provide global configurations. +--- + +# Config Provider + + +Wraps your app to provide global configurations. + + + + + +## Anatomy + +Import the component. + +```vue + + + +``` + + +## API Reference + +### Config Provider + +When creating localized apps that require right-to-left (RTL) reading direction, you need to wrap your application with the `ConfigProvider` component to ensure all of the primitives adjust their behavior based on the `dir` prop. + +You can also change the global behavior of `bodylock` for components such as `Alert`, `DropdownMenu` and etc to fit your layout to prevent any [content shifts](https://github.com/radix-vue/radix-vue/issues/385). + + + + +## Example + +Use the config provider. + +Set global direction to `rtl`, and scroll body behavior to `false` (will not set any padding/margin). + +```vue + + + +``` + \ No newline at end of file diff --git a/docs/content/utilities/use-id.md b/docs/content/utilities/use-id.md index 3f7d251ad..5e8ef2fec 100644 --- a/docs/content/utilities/use-id.md +++ b/docs/content/utilities/use-id.md @@ -3,8 +3,6 @@ title: useId description: Generate random id --- - - # useId diff --git a/docs/content/utilities/visually-hidden.md b/docs/content/utilities/visually-hidden.md new file mode 100644 index 000000000..f4b1c3f84 --- /dev/null +++ b/docs/content/utilities/visually-hidden.md @@ -0,0 +1,81 @@ +--- +title: Visually Hidden +description: Hides content from the screen in an accessible way. +--- + +# Visually Hidden + + +Hides content from the screen in an accessible way. + + + + + +## Anatomy + +Import the component. + +```vue + + + +``` + +## Basic example + +Use the visually hidden primitive. + +```vue + + + +``` + + + +## API Reference + +### Root + +Anything you put inside this component will be hidden from the screen but will be announced by screen readers. + + + +## Accessibility + +This is useful in certain scenarios as an alternative to traditional labelling with `aria-label` or `aria-labelledby`. \ No newline at end of file diff --git a/packages/radix-vue/constant/components.ts b/packages/radix-vue/constant/components.ts index 16f33bb7b..a221726e1 100644 --- a/packages/radix-vue/constant/components.ts +++ b/packages/radix-vue/constant/components.ts @@ -275,6 +275,10 @@ export const components = { 'Primitive', 'Slot', ], + + VisuallyHidden: [ + 'VisuallyHidden', + ], } export const utilities = { diff --git a/packages/radix-vue/src/ConfigProvider/ConfigProvider.vue b/packages/radix-vue/src/ConfigProvider/ConfigProvider.vue index 774952ea1..f2efbe147 100644 --- a/packages/radix-vue/src/ConfigProvider/ConfigProvider.vue +++ b/packages/radix-vue/src/ConfigProvider/ConfigProvider.vue @@ -17,6 +17,10 @@ export interface ConfigProviderProps { * @defaultValue 'ltr' */ dir?: Direction + /** + * The global scroll body behavior of your application. This will be inherited by the related primitives. + * @type boolean | ScrollBodyOption + */ scrollBody?: boolean | ScrollBodyOption } diff --git a/packages/radix-vue/src/VisuallyHidden/index.ts b/packages/radix-vue/src/VisuallyHidden/index.ts index e39ac2d4e..d4d088fab 100644 --- a/packages/radix-vue/src/VisuallyHidden/index.ts +++ b/packages/radix-vue/src/VisuallyHidden/index.ts @@ -1,2 +1,2 @@ -export { default as VisuallyHidden } from './VisuallyHidden.vue' +export { default as VisuallyHidden, type VisuallyHiddenProps } from './VisuallyHidden.vue' export { default as VisuallyHiddenInput } from './VisuallyHiddenInput.vue' diff --git a/packages/radix-vue/src/index.ts b/packages/radix-vue/src/index.ts index c5504e0d8..8d680e6a4 100644 --- a/packages/radix-vue/src/index.ts +++ b/packages/radix-vue/src/index.ts @@ -30,4 +30,5 @@ export * from './ScrollArea' // utilities export { Primitive, Slot } from './Primitive' +export { VisuallyHidden } from './VisuallyHidden' export { useId, useEmitAsProps, useForwardProps, useForwardPropsEmits, useStateMachine } from './shared'