# OVHcloud Design System - Components Documentation for all React components in OVHcloud Design System. ## Accordion --- title: "Accordion" slug: accordion category: component type: overview version: 20.0.0 tokens: 324 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-accordion.txt --- # Accordion _An **Accordion** is a vertical header that reveals or hides an associated section of content._ ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultValue` | `string[]` | No | undefined | The initial value of the expanded accordion items. Use when you don't need to control the value of the accordion. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `emphasis` | `ACCORDION_EMPHASIS` | No | undefined | The emphasis preset to use, setting the visual weight of all the accordion items. | | `multiple` | `boolean` | No | undefined | Whether multiple accordion items can be expanded at the same time. | | `onChange` | `(detail: AccordionChangeDetail) => void` | No | undefined | Callback fired when the state of expanded/collapsed accordion items changes. | | `value` | `string[]` | No | undefined | The controlled value of the expanded accordion items. | ## Examples - Default - Multiple - Disabled - Item Disabled - Controlled - Emphasis - Expand Icon Position Example ## Documentation pages - [Documentation](./react-components-accordion--documentation.txt) - [Technical Information](./react-components-accordion--technical-information.txt) - [Examples](./react-components-accordion--examples.txt) --- title: "Accordion" slug: accordion category: component type: documentation version: 20.0.0 tokens: 1693 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-accordion--documentation.txt --- # Accordion _An **Accordion** is a vertical header that reveals or hides an associated section of content._ ## Overview The **Accordion** component delivers large amounts of content in a small space through progressive disclosure. The header part gives the user a high-level overview of the content allowing them to decide which sections to read. **Accordions** can make information processing and discovering more effective. However, it does hide content from the users, and it\'s important to account for a user not noticing or reading all the included content. If a user is likely to read all the content then then the usage of an **Accordion** would not be recommended as it adds an extra interaction to access the content; instead use a full scrolling page with normal headers. | | | |---|---| | Name | Accordion | | Also known as | Collapsible, FAQ | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=1-6634 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/accordion | ## Usage Use any number of elements to visually display them as a group. Several collapsible panels can co-exist in a same interface. Use this component for : * Organizing related information * Shortening pages and reducing scrolling when content is not crucial to read in full * When space is at a premium and long content cannot be displayed all at once, like on a mobile interface or in a side panel ### Dos & Don'ts **Do** - Use Accordion to progressively disclose content, especially in long or dense pages - Ensure the summary/title of each Accordion clearly communicates what it contains - Use Accordions to group related content (e.g., FAQ) - Keep the content within each panel concise and scannable - Use Accordion instead of Tab if users need to see multiple sections at once **Don't** - Don't nest Accordions inside each other - Don't use Accordion to hide critical information needed for completing a task - Don't use vague or generic titles like "Section 1", they should be descriptive - Don't expose a lot of content in the title ### Best Practices in Context 1. **Accordion** 2. **Header** 3. **Panel** ## Placement The **Accordion** component is adjusted to the parent's width. It can vary based on the content, layout, and page design. By default, the **Accordion** content is left-aligned in its container, as the header does. It can be placed within main page content or inside a side container (as panels, or tiles). ## Behavior An **Accordion** can be hovered, focused, clicked and disabled. **Accordion** has two states : collapsed and expanded. It is collapsed by default. When triggering the header part, the panel part should react as expanding or collapsing, depending on what previous state it had. The mouse cursor acts as a clickable area on the Header part of the component. The **Icon** helps the user to know if the **Accordion** is collapsed or expanded : * Collapsed : chevron points right * Expanded : chevron points down The Header part of this component acts like a button, with hover, focus and active styles. With the `low` emphasis, hovering only changes the cursor, as there is no border or background to highlight. Same behavior and styling applies to both Desktop and Mobile modes. ## Variation ### Emphasis The emphasis sets the visual weight of the **Accordion**, not the importance of its content. It applies to all its items. - **High**: the panel of an open item sits on a muted surface that sets it apart from the header, with the `medium` borders. Use it when the **Accordion** must stand out from the surrounding content. - **Medium** _(default)_: items are outlined by borders, on the raised surface. - **Low**: no border nor background: spacing separates the items. Use it in a dense layout, or when the **Accordion** is already inside a framed container (a Card, a side panel). Every emphasis supports the disabled state, the multiple mode and both expand icon positions. The keyboard focus stays visible on the header in every emphasis. ```tsx
High emphasis Lorem ipsum dolor sit amet. High emphasis Lorem ipsum dolor sit amet. Medium emphasis (default) Lorem ipsum dolor sit amet. Medium emphasis (default) Lorem ipsum dolor sit amet. Low emphasis Lorem ipsum dolor sit amet. Low emphasis Lorem ipsum dolor sit amet.
``` ## Navigation ### Focus Management The **Accordion** header can receive keyboard focus and is part of the standard tab order. Focus remains on the header after toggling the section. If the **Accordion** is disabled, it does not receive focus and cannot be activated via keyboard. ### General Keyboard Shortcuts Pressing `Enter` or `Space` on a focused **Accordion** header toggles its expansion or collapse. Pressing `Escape` does not close an expanded **Accordion** section (unless additional custom behavior is implemented). ### Navigation between sections If multiple **Accordions** exist, users can navigate between headers using the `Tab` key. There is no looping between headers: pressing `Tab` on the last header moves focus to the next interactive element outside the Accordion. Arrow keys (`Arrow Up` / `Arrow Down`) do not move between **Accordions** by default. ## Accessibility This component complies with the [Accordion WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion). --- title: "Accordion" slug: accordion category: component type: technical-information version: 20.0.0 tokens: 617 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-accordion--technical-information.txt --- # Accordion ## Accordion This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultValue` | `string[]` | No | undefined | The initial value of the expanded accordion items. Use when you don't need to control the value of the accordion. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `emphasis` | `ACCORDION_EMPHASIS` | No | undefined | The emphasis preset to use, setting the visual weight of all the accordion items. | | `multiple` | `boolean` | No | undefined | Whether multiple accordion items can be expanded at the same time. | | `onChange` | `(detail: AccordionChangeDetail) => void` | No | undefined | Callback fired when the state of expanded/collapsed accordion items changes. | | `value` | `string[]` | No | undefined | The controlled value of the expanded accordion items. | ## AccordionContent _No specific property._ ## AccordionItem This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `disabled` | `boolean` | No | undefined | Whether the accordion item is disabled. | | `value` | `string` | Yes | undefined | The value of the accordion item. | ## AccordionTrigger This component extends all the native ` ``` Screen readers will announce the text content. ### Icon Button If a **Button** contains only an icon, it must include an [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label) to provide context. ```tsx ``` Screen readers will announce the label. ### Using aria-labelledby for additional context When a **Button** is associated with an existing label, content is read by screen readers when the **Button** receives focus. ```tsx <> Filter your search results ``` When the **Button** is focused, the screen reader will announce the linked label. --- title: "Button" slug: button category: component type: technical-information version: 20.0.0 tokens: 2205 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-button--technical-information.txt --- # Button ## Button This component extends all the native ` ``` ## Status ```tsx <> ``` ## Loading ```tsx ``` ## Size ```tsx <> ``` ## Emphasis ```tsx <> ``` ## Accessibility Explicit Text Content ```tsx ``` ## Accessibility Icon Only ```tsx ``` ## Accessibility Bad Practice Icon Only ```tsx ``` ## Accessibility Labelled By ```tsx <> Filter your search results ``` ## Accessibility Bad Practice Labelled By ```tsx <> Filter your search results ``` ## Accessibility Bad Practices Role Status ```tsx { const [message, setMessage] = useState(''); const handleClick = () => { setMessage('Copied to clipboard.'); }; return ( <> { message } ); } ``` ## Accessibility Role Status ```tsx { const [message, setMessage] = useState(''); const handleClick = () => { setMessage('Copied to clipboard.'); }; return ( <> { message } ); } ``` ## Accessibility Bad Practices Role Alert ```tsx { const [error, setError] = useState(''); const handleClick = () => { setError('A critical error occurred while saving.'); }; return ( <> { error } ); } ``` ## Accessibility Role Alert ```tsx { const [error, setError] = useState(''); const handleClick = () => { setError('A critical error occurred while saving!'); }; return ( <> { error } ); } ``` ## Button Group --- title: "Button Group" slug: button-group category: component type: overview version: 20.0.0 tokens: 276 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-button-group.txt --- # Button Group ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultValue` | `(string | number | readonly string[]) & string[]` | No | undefined | The initial value of the selected items. Use when you don't need to control the value of the component. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `multiple` | `boolean` | No | undefined | Whether multiple items can be selected at the same time. | | `onValueChange` | `(detail: ButtonGroupValueChangeDetail) => void` | No | undefined | Callback fired when the selection changes. | | `size` | `'xs' | 'sm' | 'md'` | No | undefined | The size preset to use. | | `value` | `string[]` | No | undefined | The controlled value of the selected items. | ## Examples - Default - Disabled - Disabled Item - Controlled - Multiple - Size ## Documentation pages - [Documentation](./react-components-button-group--documentation.txt) - [Technical Information](./react-components-button-group--technical-information.txt) - [Examples](./react-components-button-group--examples.txt) --- title: "Button Group" slug: button-group category: component type: documentation version: 20.0.0 tokens: 745 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-button-group--documentation.txt --- # Button Group ## Overview The **Button Group** component arranges multiple related button elements into a single, cohesive container. It enables users to make selections from a set of related options, either allowing one or multiple active states depending on configuration. | | | |---|---| | Name | ButtonGroup | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/lllHUGUkhU6rZKAracs1Ig/ODS---UI-Kit | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/button-group | ## Usage Use a **Button Group** when multiple buttons represent a set of related options or actions. It is commonly used for: - Toggle sets for text formatting or styling. - Filtering or grouping options within a toolbar. - Segmented controls in compact layouts. ### Dos & Don'ts **Do** - Use Button Group for logically related actions - Keep labels short - Use single selection for mutually exclusive choices - Use multiple selection when combined states are allowed **Don't** - Group unrelated actions together - Mix icon-only and text-only buttons inconsistently - Overcrowd toolbars with too many grouped options ### Best Practices in Context 1. **ButtonGroup** 2. **Inactive buttons** 3. **Active buttons** ## Behavior **Button Group** buttons can be focused and triggered. **Button Group** or its buttons can be disabled. ### Single Selection Only one button in the group can be selected at a time. Selecting a new button automatically deselects the previously selected one. ### Multiple Selection Several buttons can be selected simultaneously. Each button toggles independently between selected and unselected states. ### Unselected State It may be allowed that no button is selected at all, when the user can clear all selections (e.g., "No filter applied"). ## Navigation ### Focus Management When the **Button Group** receives focus, it is set on the first button. Disabled buttons are skipped in the focus order and cannot be activated. Focus remains within the group when navigating between items using arrow keys. ### General Keyboard Shortcuts Pressing `Tab` moves focus to the first button in the group. Pressing `Shift` + `Tab` moves focus to the previous focusable element outside the **Button Group**. Pressing `Arrow Right` moves focus to the next button in the group. Pressing `Arrow Left` moves focus to the previous item in the group. Pressing `Home` (or `fn` + `Arrow Left`) moves focus to the first button. Pressing `End` (or `fn` + `Arrow Right`) moves focus to the last button. Pressing `Space` or `Enter` activates or deactivates the focused button, updating the selection immediately. ## Accessibility The **Button Group** component handles by itself the accessibility requirements regarding the control grouping. Though you need to ensure that each of your items follows the [Button Accessibility Best Practices](https://ovh.github.io/design-system/v20.0.0/components/button). --- title: "Button Group" slug: button-group category: component type: technical-information version: 20.0.0 tokens: 327 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-button-group--technical-information.txt --- # Button Group ## ButtonGroup | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultValue` | `(string | number | readonly string[]) & string[]` | No | undefined | The initial value of the selected items. Use when you don't need to control the value of the component. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `multiple` | `boolean` | No | undefined | Whether multiple items can be selected at the same time. | | `onValueChange` | `(detail: ButtonGroupValueChangeDetail) => void` | No | undefined | Callback fired when the selection changes. | | `size` | `'xs' | 'sm' | 'md'` | No | undefined | The size preset to use. | | `value` | `string[]` | No | undefined | The controlled value of the selected items. | ## ButtonGroupItem This component extends all the native ` New file Open file Save file No results found. ``` ### CommandGroup naming In the case of several groups, it is recommended to provide an accessible name for each group. - Either by using the `heading` prop on **CommandGroup**, which renders a visible header, - or by using `aria-label` to provide an accessible name without a visible header. `aria-label` takes precedence. ```tsx New file Open file Some help Some more help No results found. ``` ### Disabled options To mark a **CommandOption** as non-interactive, use `aria-disabled="true"` instead of the native `disabled` attribute. This is required because **CommandOption** renders a **div** with `role="option"`, which does not support the native `disabled` attribute. ```tsx New file Open file Save file Some help Some more help No results found. ``` --- title: "Command" slug: command category: component type: technical-information version: 20.0.0 tokens: 1146 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-command--technical-information.txt --- # Command ## Command | Property | Type | Required | Default | Description | |---|---|---|---|---| | `backdropStyle` | `CSSProperties` | No | undefined | Custom style applied to the modal backdrop. Useful if you want to override the backdrop z-index. | | `closeOnEscape` | `boolean` | No | undefined | Whether to close the modal when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | undefined | Whether to close the modal when the outside is clicked. | | `defaultOpen` | `boolean` | No | undefined | The initial open state of the modal. Use when you don't need to control the open state of the modal. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `initialFocusedElement` | `() => null | HTMLElement` | No | undefined | Element that receive the focus when the dialog is opened. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `onOpenChange` | `(detail: ModalOpenChangeDetail) => void` | No | undefined | Callback fired when the modal open state changes. | | `open` | `boolean` | No | undefined | The controlled open state of the modal. | | `positionerStyle` | `CSSProperties` | No | undefined | Custom style applied to the overlay positioner. Useful if you want to override the overlay z-index. | ## CommandContent This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `createPortal` | `boolean` | No | undefined | Whether the component should be rendered in the DOM close to the body tag. | ## CommandEmpty This component extends all the native `
` attributes. _No specific property._ ## CommandFilter | Property | Type | Required | Default | Description | |---|---|---|---|---| | `clearable` | `boolean` | No | undefined | Whether the clear button is displayed. | | `endContent` | `ReactNode` | No | undefined | Decorative content displayed inside the field, after the value and before the action buttons (a unit, an icon, a ghost button). Never part of the input value. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | | `loading` | `boolean` | No | undefined | Whether the component is in loading state. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `maskOption` | `object` | No | undefined | Masked display options. | | `onClear` | `() => void` | No | undefined | Callback fired when the input value is cleared. | | `startContent` | `ReactNode` | No | undefined | Decorative content displayed inside the field, before the value (a currency symbol, an icon, a fixed scheme such as `https://`). Never part of the input value. | | `type` | `'number' | 'email' | 'search' | 'time' | 'text' | 'url' | 'password'` | No | undefined | The input type. | | `value` | `string | number | readonly string[]` | No | undefined | The controlled filter query. When set, the built-in option filtering is fully disabled: the consumer owns the query state (via `onChange`) and is responsible for rendering only the matching options. | ## CommandGroup This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `heading` | `string` | No | undefined | - | ## CommandList This component extends all the native `
` attributes. _No specific property._ ## CommandOption This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `onSelect` | `() => void` | No | undefined | Called when the option is selected via click or Enter. | ## CommandTrigger | Property | Type | Required | Default | Description | |---|---|---|---|---| | `asChild` | `boolean` | No | undefined | Use the provided child element as the default rendered element, combining their props and behavior. Be careful to pass an actual Node, not a Fragment. | | `value` | `string` | No | undefined | - | ## CSS Variables | Variable | Default value | |---|---| | `--ods-command-width` | `380px` | | `--ods-command-padding-vertical` | `calc(var(--ods-semantic-size-space-inset-block) * 2)` | | `--ods-command-padding-horizontal` | `calc(var(--ods-semantic-size-space-inset-inline) * 2)` | | `--ods-state-is-disabled-opacity` | `var(--ods-semantic-opacity-disabled)` | --- title: "Command" slug: command category: component type: examples version: 20.0.0 tokens: 2056 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-command--examples.txt --- # Command ## Default ```tsx item 1 item 2 No results found. ``` ## Controlled ```tsx { const [isOpen, setIsOpen] = useState(false); function onOpenChange({ open }: { open: boolean }) { setIsOpen(open); } function openCommand() { setIsOpen(true); } return ( <> New file Open file Save file No results found. ); } ``` ## Controlled Filtering ```tsx { const [query, setQuery] = useState(''); const actions = ['New file', 'Open file', 'Save file']; const visibleActions = actions.filter((action) => !query || action.toLowerCase().includes(query.toLowerCase())); return ( setQuery(e.target.value) } placeholder="Search..." value={ query } /> { visibleActions.map((action) => ( { action } )) } No results found. ); } ``` ## With Shortcuts ```tsx New file ⌘+n Open file Save file No results found. ``` ## With On Select ```tsx <> toast('New file', { toasterId: 'command-on-select' }) }>New file toast('Open file', { toasterId: 'command-on-select' }) }>Open file toast('Save file', { toasterId: 'command-on-select' }) }>Save file No results found. ``` ## Without Filter ```tsx New file Open file Save file Undo Redo No results found. ``` ## Empty State ```tsx No results found. ``` ## Accessibility Labels ```tsx New file Open file Save file No results found. ``` ## Accessibility Filter Label ```tsx New file Open file Save file No results found. ``` ## Accessibility Group Names ```tsx New file Open file Some help Some more help No results found. ``` ## Accessibility Disabled Option ```tsx New file Open file Save file Some help Some more help No results found. ``` ## Data Table --- title: "Data Table" slug: data-table category: component type: overview version: 20.0.0 tokens: 636 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-data-table.txt --- # Data Table ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `columns` | `DataTableColumnDef[]` | Yes | undefined | The columns definitions. | | `data` | `T[]` | Yes | undefined | The table data to display. | | `enableMultiRowSelection` | `boolean` | No | undefined | Whether the multi row selection is enabled. | | `enableRowSelection` | `boolean | (row: DataTableRow) => boolean` | No | undefined | Whether the row selection is enabled. | | `enableSorting` | `boolean` | No | undefined | Whether the column sorting is enabled. | | `getRowId` | `(originalRow: T, index: number, parent: DataTableRow) => string` | No | undefined | By default, the component will look for an id attribute in a data item to identify each row. Using this function, you can define another attribute to use instead (like uuid). | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `loading` | `boolean` | No | undefined | Whether the table data are in a loading state. This will replace each cell with a Skeleton. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `manualSorting` | `boolean` | No | undefined | Whether the sorting is handled outside of the table. Use this is the sorting is managed on server-side. | | `onColumnPinningChange` | `OnChangeFn` | No | undefined | Callback fired when the pinned columns changes. | | `onColumnVisibilityChange` | `OnChangeFn` | No | undefined | Callback fired when the column visibility changes. | | `onRowSelectionChange` | `OnChangeFn` | No | undefined | Callback fired when the selected rows changes. | | `onSortingChange` | `OnChangeFn` | No | undefined | Callback fired when the columns sorting changes. | | `state` | `DataTableState` | No | undefined | The controlled table values. | | `stickyHeader` | `boolean` | No | undefined | Whether the header should be sticky. | ## Examples - Default - Empty - Pagination Example - Pinned Columns - State Controlled - Sorting Custom Function - Sorting Disabled Columns - Sorting Controlled - Visibility Example - Accessibility I18n ## Documentation pages - [Documentation](./react-components-data-table--documentation.txt) - [Technical Information](./react-components-data-table--technical-information.txt) - [Examples](./react-components-data-table--examples.txt) --- title: "Data Table" slug: data-table category: component type: documentation version: 20.0.0 tokens: 3080 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-data-table--documentation.txt --- # Data Table ## Overview The `Data Table` component provides a structured and flexible way to display, explore, and interact with tabular data. It is designed as a core component, intended to support a wide range of use cases while remaining composable, scalable, andproduct-agnostic. | | | |---|---| | Name | DataTable | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/KKF2yPJ1fGICU7z9usG7Pl/ODS---UI-Kit?node-id=16269-23952&p=f&t=AvtT3fJhAIPZ0qbf-0 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/data-table | ## Usage The `Data Table` is used to present collections of structured data and enable users to: - Browse and scan information efficiently. - Sort and organize data. - Select one or multiple rows. - Perform actions on individual row or in bulk. - Interact with large datasets through pagination, search, and refresh. Typical use cases include: - Administration panels. - Management interfaces. - Reporting and operational dashboards. - Configuration screens. ### Dos & Don'ts **Do** - Use a Data Table for managing collections of structured data - Use composition to inject business-specific actions and logic - Combine selection with bulk actions for efficiency **Don't** - Use a Data Table for simple, static content - Overload the table with too many visible actions - Trigger destructive actions without confirmation - Assume all rows behave identically in bulk operations ### Best Practices in Context 1. **Data Table** 2. **Header cell** 3. **Body cell** 4. **Column sorting** ## Placement The `Data Table` is typically placed as the main content of a page or section. It should: - Expand horizontally to fit its container. - Manage internal scrolling when necessary. - Not overflow or break surrounding layouts. ## Behavior ### Data & State Ownership The `Data Table` does not own data. Data fetching, transformation, and persistence are handled by the integrator. The component is responsible for rendering the provided dataset and reflecting externally managed states such as loading, sorting, selection, and pagination. The integrator is responsible for: - Providing the data to display. - Handling data fetching and refreshing. - Managing all business rules and permissions. - Synchronizing external state with the `Data Table` visual state. ### Row Selection The `Data Table` supports row selection via checkboxes or radio buttons. The `Data Table` is responsible for: - Rendering selection controls. - Handling user interaction for selecting and deselecting rows. - Visually reflecting the current selection state. - Exposing selection changes to the integrator. The integrator is responsible for: - Storing and managing the selection state. - Defining whether selection is single or multiple. - Deciding how selection behaves accross pagination or refresh. Disabled rows are not selectable. ### Column Sorting The `Data Table` supports column-based sorting through interactions with column headers. The `Data Table` is responsible for: - Rendering sortable and non-sortable column headers. - Managing user interactions on sortable headers. - Displaying visual indicators for sorting state (unsorted, ascending, descending). The integrator is reponsible for: - Implemeting the sorting logic (if done server-side). - Synchronizing the active sorting state with the `Data Table`. The `Data Table` can support either single-column sorting, where only one column can be sorted at a time, or multi-column sorting, where users can sort by multiple columns simultaneously. Non-sortable columns don't react to sorting interactions. ### Pinned columns The `Data Table` supports pinning columns to keep them visible during horizontal scrolling. The `Data Table` is responsible for: - Maintaining the pinned column position during scroll. - Providing a visual separation between pinned and scrollable columns. The integrator is responsible for: - Defining which columns are pinned. - Ensuring that pinned columns are used appropriately (e.g. selection or actions). Pinned columns remain fully interactive and accessible. ### Disabled Rows The `Data Table` supports disabled rows to represent non-interactive or restricted items. The `Data Table` is responsible for: - Rendering disabled rows with a distinct visual style. - Preventing interaction with disabled rows. The integrator is responsible for: - Defining which rows are disabled and why. - Optionnaly providing explanatory messaging (e.g. tooltip). Disabled rows must not participate in selection or bulk actions. ### Sticky Header The `Data Table` may support sticky headers to maintain access to key controls during vertical scrolling. The `Data Table` is responsible for: - Keeping the header visually fixed within the table container. The integrator is responsible for: - Deciding whether sticky behavior is enabled. - Ensuring that injected content (actions, menus, tooltips) behave correctly within the sticky area. Sticky behavior must not interfere with interactions such as sorting, tooltips, or menus. ### Row-level Actions (Ellipsis Menu) Rows may expose contextual actions via an ellipsis menu. The integrator is responsible for: - Rendering the menu trigger. - Providing the menu content. - Defining actions behavior and permissions. - Managing disabled or loading states per action. ### Global Table Actions A dedicated area associated with the `Data Table` for global actions, intended to host at least one primary action (e.g., "Create", "Add", "Import"), but may contain additional actions if required by the product context. The integrator is responsible for: - Defining the actions themselves. - Handling their behavior, permissions, and side effects. - Supporting disabled and loading visual states. ### Bulk actions Bulk actions are actions applied to a set of selected rows. The integrator is responsible for: - Rendering the bulk actions area when one or more rows are selected. - Defining bulk actions and their behavior. - Handling business rules and permissions. - Determining the eligibility of selected rows for each action. When a selection includes rows with mixed eligibility, the `Data Table` must support integrator-defined strategies such as disabling the action, allowing partial execution with confirmation, or dinamycally adjusting available actions. ### Header tooltips Displaying tooltips attached to column headers. The integrator is responsible for: - Rendering tooltip triggers. - Providing tooltip content. Tooltips must not obstruct sorting or other header interactions. ### Search Associating a global search input to the `Data Table`. The integrator is responsible for: - Providing the search input. - Implementing search logic. - Visually indicating when a search is active. - Handling empty and loading states resulting from search. ### Pagination Adding paginated data display to the `Data Table`. The integrator is responsible for: - Rendering pagination controls. - Displaying the current page state. - Providing pagination data (current page, total pages, total items). - Handling page changes and data updates. The behavior of selection across page changes must be explicitly defined by the integrator. ### Refresh Exposing a refresh control allowing users to explicitly request a data reload. The integrator is responsible for: - Rendering the refresh trigger. - Displaying a loading state when refresh is in progress. - Implementing the refresh logic. - Updating the data and loading state accordingly. When a refresh is triggered while a loading state is already active, the refresh action must be disabled or ignored to prevent duplicate requests. If rows were selected prior to a refresh, it is recommended to reset them. ### Tags assignment Supporting tag assignment workflows through composition, using a modal. Tag assignment is treated as a business-specific action and is not implemented by the `Data Table` component. The tag assignment modal may be triggered from different entry points, such as a row-level action for example. The integrator is responsible for: - Defining when an where the tag assignment action is available. - Rendering the modal and its trigger. - Handling the association between rows and tags. - Providing existing tags to the modal. - Resolving conflicts with already assigned tags. All error handling, messaging, and resolution strategies are the responsibility of the integrator. ### Editable Content Allowing editable content to be injected through composition to the `Data Table`. The integrator is responsible for: - Rendering editable content/component (ODS or custom). - Managing side effects of editing (data updates, refresh, notifications). ## Navigation ### Focus Management The `Data Table` is fully navigable using the keyboard. When focus enters the `Data Table`, it is placed on the first focusable element within the table, depending on the current configuration. This may include: - a global table action. - a sortable column header. - a row selection checkbox. - a focusable action within the first row. Focus is never trapped inside the `Data Table`. Users can move focus into and out of the component using standard keyboard navigation. If a header is not sortable or interactive, it must not receive focus. Disabled rows do not receive focus. ### General Keyboard Shortcuts #### Table Navigation Keyboard navigation within the `Data Table` follows a predictable, linear order: - Pressing `Tab` moves focus forward through focusable elements inside the table. - Pressing `Shift` + `Tab` moves focus backward. #### Column Header Navigation When a column header is focusable: - Pressing `Enter` or `Space` triggers the primary header action (e.g. sorting). - Tooltip triggers in headers are reachable via keyboard focus. #### Row Selection via Keyboard Row selection controls are keyboard accessible. - Pressing `Space` toggles the selection state of the focused row checkbox. - The "select all" checkbox (when present) can be toggled using `Space`. Disabled rows cannot be selected via keyboard. #### Row-Level Actions Row-level actions (such as ellipsis menus) are reachable via keyboard navigation (`Space` or `Enter` depending on the focusabled element). ## Accessibility To ensure the `Data Table` component is fully accessible, it is essential to follow best practices for structuring tables with the correct attributes and a global caption to provide users with context. Please follow the [W3C technique](https://www.w3.org/TR/WCAG20-TECHS/H63) for integrating them correctly. We also recommend referring to the [WCAG guidelines](https://www.w3.org/WAI/tutorials/tables/) for building accessible `Data Tables`. ### Sortable columns Each sortable column header renders a button named after the header content, and the sorted column exposes its direction with `aria-sort`. The button also carries a description, "Sortable column" by default, that screen readers announce when the button receives the focus. It is a description rather than part of the name, because screen readers repeat the column header name in every cell of the column. The description follows the `locale` prop. To reword it, use the `i18n` prop: ```tsx { type Member = { firstName: string; lastName: string; role: string; } const data: Member[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', role: 'Admin' }, { firstName: 'Jane', lastName: 'Smith', role: 'User' }, { firstName: 'Bob', lastName: 'Johnson', role: 'Manager' }, ], []); const columns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); return ( ); } ``` Screen readers will announce the header button with its description, and the sort direction of the sorted column. --- title: "Data Table" slug: data-table category: component type: technical-information version: 20.0.0 tokens: 625 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-data-table--technical-information.txt --- # Data Table ## DataTable | Property | Type | Required | Default | Description | |---|---|---|---|---| | `columns` | `DataTableColumnDef[]` | Yes | undefined | The columns definitions. | | `data` | `T[]` | Yes | undefined | The table data to display. | | `enableMultiRowSelection` | `boolean` | No | undefined | Whether the multi row selection is enabled. | | `enableRowSelection` | `boolean | (row: DataTableRow) => boolean` | No | undefined | Whether the row selection is enabled. | | `enableSorting` | `boolean` | No | undefined | Whether the column sorting is enabled. | | `getRowId` | `(originalRow: T, index: number, parent: DataTableRow) => string` | No | undefined | By default, the component will look for an id attribute in a data item to identify each row. Using this function, you can define another attribute to use instead (like uuid). | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `loading` | `boolean` | No | undefined | Whether the table data are in a loading state. This will replace each cell with a Skeleton. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `manualSorting` | `boolean` | No | undefined | Whether the sorting is handled outside of the table. Use this is the sorting is managed on server-side. | | `onColumnPinningChange` | `OnChangeFn` | No | undefined | Callback fired when the pinned columns changes. | | `onColumnVisibilityChange` | `OnChangeFn` | No | undefined | Callback fired when the column visibility changes. | | `onRowSelectionChange` | `OnChangeFn` | No | undefined | Callback fired when the selected rows changes. | | `onSortingChange` | `OnChangeFn` | No | undefined | Callback fired when the columns sorting changes. | | `state` | `DataTableState` | No | undefined | The controlled table values. | | `stickyHeader` | `boolean` | No | undefined | Whether the header should be sticky. | ## DataTableBody This component extends all the native `` attributes. _No specific property._ ## DataTableEmpty This component extends all the native `` attributes. _No specific property._ ## DataTableHead This component extends all the native `` attributes. _No specific property._ ## Enums ### DATA_TABLE_I18N - `sortableColumn` = `dataTable.column.sortable` --- title: "Data Table" slug: data-table category: component type: examples version: 20.0.0 tokens: 3916 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-data-table--examples.txt --- # Data Table ## Default ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@example.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@example.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@example.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); return ( ); } ``` ## Empty ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); return ( Empty table data ); } ``` ## Pagination Example ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; } const PAGE_LIMIT = PAGINATION_PER_PAGE.option_10; const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); const [data, setData] = useState(Array(PAGE_LIMIT).fill({})); const [page, setPage] = useState(0); const [total, setTotal] = useState(0); const fetchData = useCallback(async (page: number) => { return fetch(`https://dummyjson.com/users?limit=${PAGE_LIMIT}&skip=${PAGE_LIMIT * (page - 1)}&select=firstName,lastName,age,email,role`) .then((res) => res.json()) .then(({ total, users }) => ({ total, users, })); }, []); useEffect(() => { fetchData(page).then(({ total, users }) => { setData(users); setTotal(total); }); }, [page]); return (
Paginated Table setPage(page) } page={ page } pageSize={ PAGE_LIMIT } totalItems={ total }>
); } ``` ## Pinned Columns ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@example.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@example.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@example.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); const pinningState = useMemo(() => ({ left: ['age'], right: ['email'], }), []); return ( Empty table data ); } ``` ## State Controlled ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@domain2.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@domain1.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@domain3.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); const [sortingState, setSortingState] = useState([{ id: 'role', desc: true, }]); return ( Controlled sorted table ); } ``` ## Sorting Custom Function ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@domain2.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@domain1.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@domain3.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email', sortingFn: (rowA, rowB, columnId) => { const valueA = rowA.getValue(columnId).split('@')[1].split('.')[0]; const valueB = rowB.getValue(columnId).split('@')[1].split('.')[0]; return valueA.localeCompare(valueB); }, }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); return ( Email sorted by domain ); } ``` ## Sorting Disabled Columns ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@domain2.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@domain1.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@domain3.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName', enableSorting: false }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role', enableSorting: false }, ], []); return ( Sort disabled on some columns ); } ``` ## Sorting Controlled ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@domain2.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@domain1.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@domain3.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); const [sortingState, setSortingState] = useState([{ id: 'role', desc: true, }, { id: 'lastName', desc: true, }]); return ( Controlled sorting ); } ``` ## Visibility Example ```tsx { type Person = { firstName: string; lastName: string; age: number; email: string; role: string; uuid: string; } const sampleData: Person[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', age: 30, email: 'john.doe@domain2.com', role: 'Admin', uuid: '5ae49b94-9ceb-4612-a087-4079a812bb0b', }, { firstName: 'Jane', lastName: 'Smith', age: 25, email: 'jane.smith@domain1.com', role: 'User', uuid: 'fb1c391c-bd88-4b96-ba39-8ab2a95d50bd', }, { firstName: 'Bob', lastName: 'Johnson', age: 35, email: 'bob.johnson@domain3.com', role: 'Manager', uuid: 'a83a58a6-a007-47f0-b04b-83989e502171', }, ], []); const sampleColumns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'age', header: 'Age', accessorKey: 'age' }, { id: 'email', header: 'Email', accessorKey: 'email' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); const visibileColumn= useMemo(() => ({ age: false }), []); return ( Age column hidden ); } ``` ## Accessibility I18n ```tsx { type Member = { firstName: string; lastName: string; role: string; } const data: Member[] = useMemo(() => [ { firstName: 'John', lastName: 'Doe', role: 'Admin' }, { firstName: 'Jane', lastName: 'Smith', role: 'User' }, { firstName: 'Bob', lastName: 'Johnson', role: 'Manager' }, ], []); const columns: DataTableColumnDef[] = useMemo(() => [ { id: 'firstName', header: 'First Name', accessorKey: 'firstName' }, { id: 'lastName', header: 'Last Name', accessorKey: 'lastName' }, { id: 'role', header: 'Role', accessorKey: 'role' }, ], []); return ( ); } ``` ## Datepicker --- title: "Datepicker" slug: datepicker category: component type: overview version: 20.0.0 tokens: 827 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-datepicker.txt --- # Datepicker _A **Datepicker** component is used to allow users to select a date. They can navigate through days, months and years._ ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `dateFormatter` | `(arg: DatepickerFormatterArg) => string` | No | undefined | Format the date to display in the input. | | `defaultOpen` | `boolean` | No | undefined | The initial open state of the datepicker. Use when you don't need to control the open state of the datepicker. | | `defaultValue` | `string | Date` | No | undefined | The initial selected date. Use when you don't need to control the selected date of the datepicker. | | `defaultView` | `'month' | 'day' | 'year'` | No | undefined | The default view of the calendar (day, month, year). | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `disabledDates` | `Date[]` | No | undefined | List of dates that cannot be selected. | | `disabledWeekDays` | `DATEPICKER_DAY[]` | No | undefined | List of week days that cannot be selected. | | `i18n` | `Partial` | No | undefined | Internal translations override (see Input i18n keys). | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | | `locale` | `string` | No | undefined | The locale to use when formatting the date. | | `max` | `string | Date` | No | undefined | The maximum date that can be selected. | | `maxView` | `'month' | 'day' | 'year'` | No | undefined | The maximum view of the calendar (day, month, year). | | `min` | `string | Date` | No | undefined | The minimum date that can be selected. | | `minView` | `'month' | 'day' | 'year'` | No | undefined | The minimum view of the calendar (day, month, year). | | `name` | `string` | No | undefined | The name of the form element. Useful for form submission. | | `onOpenChange` | `(detail: DatepickerOpenChangeDetail) => void` | No | undefined | Callback fired when the datepicker open state changes. | | `onValueChange` | `(detail: DatepickerValueChangeDetail) => void` | No | undefined | Callback fired when the value changes. | | `open` | `boolean` | No | undefined | The controlled open state of the datepicker. | | `overlayConfig` | `object` | No | undefined | The overlay configuration. | | `placeholder` | `string` | No | undefined | The placeholder text to display in the input. | | `positionerStyle` | `CSSProperties` | No | undefined | Custom style applied to the overlay positioner. Useful if you want to override the overlay z-index. | | `readOnly` | `boolean` | No | undefined | Whether the component is readonly. | | `required` | `boolean` | No | undefined | Whether the component is required. | | `value` | `string | null | Date` | No | undefined | The controlled selected date. | | `view` | `'month' | 'day' | 'year'` | No | undefined | The controlled view of the calendar (day, month, year). | ## Examples - Default - Disabled - Readonly - Date Formatter - Min Max - Max View - Min View - In Form Field - Accessibility Form Field - Accessibility Date Format - Accessibility I18n ## Documentation pages - [Documentation](./react-components-datepicker--documentation.txt) - [Technical Information](./react-components-datepicker--technical-information.txt) - [Examples](./react-components-datepicker--examples.txt) --- title: "Datepicker" slug: datepicker category: component type: documentation version: 20.0.0 tokens: 1922 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-datepicker--documentation.txt --- # Datepicker _A **Datepicker** component is used to allow users to select a date. They can navigate through days, months and years._ ## Overview Form Guidelines] } figmaLink="https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=26-7958" githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/datepicker" name="Datepicker"> The Datepicker component is used for selecting dates in forms and applications. It provides a user-friendly interface for choosing dates, ensuring that the date format is consistent and valid. This component can include features such as disabled dates and custom formats. | | | |---|---| | Name | undefined | | Also known as | Calendar | ## Usage **Datepicker** is used to **allow a selection of a specific date** in the near future or even past. It is **useful for scheduling, or defining user dates**. ### Dos & Don'ts **Do** - Use a Datepicker when users need to select a specific date - Choose a relevant default date when opening the calendar (e.g., default to the current year/month when not contextually set) - Add a label alongside the input to clearly indicate the expected format, especially when the placeholder disappears on input - Use a Datepicker when users need to select a single date or range of dates - Use a Datepicker for recent or near future dates - When the user has to pick dates in the distant past or future, do choose a more suitable day as Datepicker default date when it will open **Don't** - Don't rely only on placeholders to communicate the date format. Users need persistent guidance (via a label or hint) - Don't use a Datepicker when the user must select a date very far in the past or future (e.g., birthdate). Use a more accessible method like dropdowns or manual input - Don't overload the interface with too many calendar options at once - Don't default the calendar to an irrelevant month/year ### Best Practices in Context 1. **Datepicker** 2. **Date field** 3. **Icon button** 4. **Dropdown calendar** 5. **Month/Year button** 6. **Previous/Next month buttons** 7. **Week days** 8. **Day** 9. **Selected day** ## Placement A **Datepicker** can be used in a page as long as there is a need to allow users to pick a date. The date field shares the default width of every form field (280px, capped to its container), so it lines up with the other inputs of a form. To make it fill its container, give both the **Datepicker** and the **DatepickerControl** a `className` that sets `width: 100%`: the **Datepicker** wraps its control in an inline block, which a percentage on the control alone does not widen. The **Datepicker** dropdown has a fixed width and is not adjustable. ## Behavior **Opening the Datepicker** By clicking on the **Datepicker** icon button. **Closing the Datepicker** - By clicking outside the **Datepicker** dropdown - By selecting a date **Date picking mode** Navigating to previous/next month : By clicking on arrow icon [Buttons](https://ovh.github.io/design-system/v20.0.0/components/button) to navigate through months Selecting a month : By clicking on the month selection [Button](https://ovh.github.io/design-system/v20.0.0/components/button) to switch to month picking mode Picking a date : By clicking on a date **Month picking mode** Navigating to previous/next year : By clicking on arrow icon [Buttons](https://ovh.github.io/design-system/v20.0.0/components/button) to navigate through years Selecting a year : By clicking on the month selection [Button](https://ovh.github.io/design-system/v20.0.0/components/button) to switch to year picking mode Picking a month: By clicking on a month, the dropdown goes back to date picking mode **Year picking mode** Navigating to previous/next range of years : By clicking on arrow icon [Buttons](https://ovh.github.io/design-system/v20.0.0/components/button) to navigate through years Selecting a decade : By clicking on the month selection [Button](https://ovh.github.io/design-system/v20.0.0/components/button) to switch to year picking mode Picking a month: By clicking on a month, the dropdown goes back to date picking mode **Locale** Locale determines how the week days will be displayed according to the localization. The **Datepicker** supports the following locales: English (default), German, Spanish, French, Italian, Dutch, Polish and Portuguese. ## Navigation ### Focus Management The **Datepicker** icon button can receive the focus. When the dropdown calendar opens, the focus is moved to the currently selected date, or to today's date if none is selected. When the dropdown is closed (via Escape or blur), focus returns to the Datepicker trigger (the input field). ### General Keyboard Shortcuts Pressing `Escape` closes the Datepicker dropdown without selecting a date. Pressing `Tab` or `Shift` + `Tab` moves focus through dropdown controls when open. ### Navigating days - `Arrow Left`: Move to the previous day - `Arrow Right`: Move to the next day - `Arrow Up`: Move to the same weekday of the previous week - `Arrow Down`: Move to the same weekday of the next week ### Jumping within the calendar - `Home`: Move to the first day of the current month - `End`: Move to the last day of the current month - `Page Up`: Move to the same date of the previous month - `Page Down`: Move to the same date of the next month ### Selecting a date or changing view - `Enter`: Select the currently focused date and close the dropdown - Typing a valid date format (e.g., yyyy-mm-dd) in the input and pressing `Enter` will also select the date ### Navigating to month/year view - `Ctrl` / `Cmd` + `Arrow Up` (first press): Switches to month selection view - `Ctrl` / `Cmd` + `Arrow Up` (second press): Switches to year selection view - Use `Arrow` keys to move within month/year grids - Press `Enter` to confirm selection and return to the previous view - `Ctrl` / `Cmd` + `Arrow Left` / `Arrow Right`: Quickly navigate to the previous or next month from date view ## Accessibility To ensure proper accessibility, the **Datepicker** must be correctly labeled, provide clear guidance on date format and meaningful context when a clearable button is used. ### Always provide an explicit label Every **Datepicker** must have a clear and explicit label to ensure that users (especially screen reader users) understand its purpose using either **FormField** or a native label tag. ```tsx Start date: ``` Screen readers will announce the label, the field and its content. ### Provide guidance on date format Since screen readers can only interact with the **Datepicker** input field, it’s important to provide guidance on the expected date format to ensure correct input. ```tsx Start date: Expected format: DD-MM-YYYY ``` Screen readers will announce the label, the field, its content and the helper. ```tsx Start date: ``` Screen readers will announce the label, the field, its content and custom label of focused action. --- title: "Datepicker" slug: datepicker category: component type: technical-information version: 20.0.0 tokens: 1008 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-datepicker--technical-information.txt --- # Datepicker ## Datepicker This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `dateFormatter` | `(arg: DatepickerFormatterArg) => string` | No | undefined | Format the date to display in the input. | | `defaultOpen` | `boolean` | No | undefined | The initial open state of the datepicker. Use when you don't need to control the open state of the datepicker. | | `defaultValue` | `string | Date` | No | undefined | The initial selected date. Use when you don't need to control the selected date of the datepicker. | | `defaultView` | `'month' | 'day' | 'year'` | No | undefined | The default view of the calendar (day, month, year). | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `disabledDates` | `Date[]` | No | undefined | List of dates that cannot be selected. | | `disabledWeekDays` | `DATEPICKER_DAY[]` | No | undefined | List of week days that cannot be selected. | | `i18n` | `Partial` | No | undefined | Internal translations override (see Input i18n keys). | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | | `locale` | `string` | No | undefined | The locale to use when formatting the date. | | `max` | `string | Date` | No | undefined | The maximum date that can be selected. | | `maxView` | `'month' | 'day' | 'year'` | No | undefined | The maximum view of the calendar (day, month, year). | | `min` | `string | Date` | No | undefined | The minimum date that can be selected. | | `minView` | `'month' | 'day' | 'year'` | No | undefined | The minimum view of the calendar (day, month, year). | | `name` | `string` | No | undefined | The name of the form element. Useful for form submission. | | `onOpenChange` | `(detail: DatepickerOpenChangeDetail) => void` | No | undefined | Callback fired when the datepicker open state changes. | | `onValueChange` | `(detail: DatepickerValueChangeDetail) => void` | No | undefined | Callback fired when the value changes. | | `open` | `boolean` | No | undefined | The controlled open state of the datepicker. | | `overlayConfig` | `object` | No | undefined | The overlay configuration. | | `placeholder` | `string` | No | undefined | The placeholder text to display in the input. | | `positionerStyle` | `CSSProperties` | No | undefined | Custom style applied to the overlay positioner. Useful if you want to override the overlay z-index. | | `readOnly` | `boolean` | No | undefined | Whether the component is readonly. | | `required` | `boolean` | No | undefined | Whether the component is required. | | `value` | `string | null | Date` | No | undefined | The controlled selected date. | | `view` | `'month' | 'day' | 'year'` | No | undefined | The controlled view of the calendar (day, month, year). | ## DatepickerContent This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `createPortal` | `boolean` | No | undefined | Whether the component should be rendered in the DOM close to the body tag. | ## DatepickerControl This component extends all the native `` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `clearable` | `boolean` | No | undefined | Whether the clear button is displayed. | | `loading` | `boolean` | No | undefined | Whether the component is in loading state. | ## Enums ### DATEPICKER_DAY - `friday` = `5` - `monday` = `1` - `saturday` = `6` - `sunday` = `0` - `thursday` = `4` - `tuesday` = `2` - `wednesday` = `3` ### DATEPICKER_VIEW - `day` = `day` - `month` = `month` - `year` = `year` ## CSS Variables | Variable | Default value | |---|---| | `--ods-datepicker-content-padding-horizontal` | `calc(var(--ods-semantic-size-space-inset-inline) / 2)` | | `--ods-datepicker-content-padding-vertical` | `calc(var(--ods-semantic-size-space-inset-block) / 2)` | | `--ods-state-is-disabled-opacity` | `var(--ods-semantic-opacity-disabled)` | --- title: "Datepicker" slug: datepicker category: component type: examples version: 20.0.0 tokens: 590 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-datepicker--examples.txt --- # Datepicker ## Default ```tsx ``` ## Disabled ```tsx <>

Disabled:

Disabled Dates:

Disabled Week Days:

``` ## Readonly ```tsx ``` ## Date Formatter ```tsx `${date.getFullYear()}` } placeholder="yyyy"> ``` ## Min Max ```tsx ``` ## Max View ```tsx ``` ## Min View ```tsx ``` ## In Form Field ```tsx Label: ``` ## Accessibility Form Field ```tsx Start date: ``` ## Accessibility Date Format ```tsx Start date: Expected format: DD-MM-YYYY ``` ## Accessibility I18n ```tsx Start date: ``` ## Divider --- title: "Divider" slug: divider category: component type: overview version: 20.0.0 tokens: 179 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-divider.txt --- # Divider _A **Divider** component is a spacer used to add white space between two elements on a page._ ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `orientation` | `'horizontal' | 'vertical'` | No | undefined | The orientation of the divider. | | `spacing` | `'0' | '2' | '4' | '6' | '8' | '12' | '16' | '24' | '32' | '40' | '48' | '64'` | No | undefined | The spacing preset to use. | ## Examples - Default - Color - Orientation - Spacing ## Documentation pages - [Documentation](./react-components-divider--documentation.txt) - [Technical Information](./react-components-divider--technical-information.txt) - [Examples](./react-components-divider--examples.txt) --- title: "Divider" slug: divider category: component type: documentation version: 20.0.0 tokens: 720 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-divider--documentation.txt --- # Divider _A **Divider** component is a spacer used to add white space between two elements on a page._ ## Overview A **Divider** is a UI component used to separate content into clear, distinct sections, providing visual breaks between different elements or groups of content. | | | |---|---| | Name | Divider | | Also known as | Separator, Spacer, Horizontal Line | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=26-19845 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/divider | ## Usage **Divider** is used to separate content on a page. It brings clarity to a layout by dividing content in proximity. ### Dos & Don'ts **Do** - Use a Divider to visually separate content into meaningful sections or groups - Place a Divider below section titles or headers to emphasize hierarchy and structure - Use Divider to indicate content boundaries without relying solely on spacing or background changes - Keep Divider usage subtle and consistent across the layout to preserve clarity **Don't** - Don't place a Divider above section titles or headers, it breaks natural reading flow - Don't overuse Dividers on a single page, too many can create visual noise and clutter - Don't use Divider as a primary layout mechanism, prefer spacing, grouping, or cards for structure - Don't rely on Divider to fix unclear content grouping, improve the layout or hierarchy instead - Don't use Divider when spacing alone is sufficient to separate elements - Don't apply inconsistent styling (e.g., thickness, color) that breaks the visual consistency of the interface ### Best Practices in Context 1. **Divider** 2. **Spacing** ## Placement Use **Divider** between closely related content blocks or UI elements to enhance readability without adding visual noise. It works well in layouts like sidebars, menus, or cards to separate sections clearly. ## Variation ### Spacing It can be adjusted around the **Divider** to match the layout and visual rhythm of the content. ### Color The **Divider** uses the theme split color. If you need another color, for example a darker line on a light background, override its `background-color` in CSS. ### Orientation * **Horizontal** (default): separates content stacked vertically (for example, between sections of a page) * **Vertical**: separates content arranged horizontally (for example, between items in a toolbar, breadcrumbs, inline actions, or columns) ## Navigation The **Divider** component is purely visual and does not receive keyboard focus. It serves as a separator between content sections and does not impact keyboard navigation. ## Accessibility The **Divider** provides a clear visual separation between content sections which can help users with visual impairments to better understand the layout and structure of the page. --- title: "Divider" slug: divider category: component type: technical-information version: 20.0.0 tokens: 171 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-divider--technical-information.txt --- # Divider ## Divider This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `orientation` | `'horizontal' | 'vertical'` | No | undefined | The orientation of the divider. | | `spacing` | `'0' | '2' | '4' | '6' | '8' | '12' | '16' | '24' | '32' | '40' | '48' | '64'` | No | undefined | The spacing preset to use. | ## Enums ### DIVIDER_ORIENTATION - `horizontal` = `horizontal` - `vertical` = `vertical` ### DIVIDER_SPACING - `_0` = `0` - `_12` = `12` - `_16` = `16` - `_2` = `2` - `_24` = `24` - `_32` = `32` - `_4` = `4` - `_40` = `40` - `_48` = `48` - `_6` = `6` - `_64` = `64` - `_8` = `8` --- title: "Divider" slug: divider category: component type: examples version: 20.0.0 tokens: 230 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-divider--examples.txt --- # Divider ## Default ```tsx ``` ## Color ```tsx <> ``` ## Orientation ```tsx <> ``` ## Spacing ```tsx <> ``` ## Drawer --- title: "Drawer" slug: drawer category: component type: overview version: 20.0.0 tokens: 402 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-drawer.txt --- # Drawer ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `backdrop` | `boolean` | No | undefined | Whether a backdrop is displayed. With a backdrop, the drawer behaves as a modal: focus is trapped, the rest of the page is inert and its scroll is locked. | | `backdropStyle` | `CSSProperties` | No | undefined | Custom style applied to the drawer backdrop. Useful if you want to override the backdrop z-index. | | `closeOnEscape` | `boolean` | No | undefined | Whether to close the drawer when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | undefined | Whether to close the drawer when the user clicks or moves the focus outside of it. Defaults to true when a backdrop is displayed, false otherwise. | | `defaultOpen` | `boolean` | No | undefined | The initial open state of the drawer. Use when you don't need to control the open state of the drawer. | | `onOpenChange` | `(detail: DrawerOpenChangeDetail) => void` | No | undefined | Callback fired when the drawer open state changes. | | `open` | `boolean` | No | undefined | The controlled open state of the drawer. | | `positionerStyle` | `CSSProperties` | No | undefined | Custom style applied to the overlay positioner. | ## Examples - Default - Backdrop - Position - Overlay Elements - Controlled - Accessibility Aria Labelled By - Accessibility Aria Label ## Documentation pages - [Documentation](./react-components-drawer--documentation.txt) - [Technical Information](./react-components-drawer--technical-information.txt) - [Examples](./react-components-drawer--examples.txt) --- title: "Drawer" slug: drawer category: component type: documentation version: 20.0.0 tokens: 1714 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-drawer--documentation.txt --- # Drawer The Drawer component provides a sliding panel that reveals additional content without navigating away from the current page. ## Overview | | | |---|---| | Name | Drawer | | Also known as | Sidenav, Panel | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/5BA2ZwZaX2bzfiWwTyMpQH/ODS---UI-Kit?node-id=5488-15121&p=f&t=gPfKLQM0iEuF2FXm-0 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/drawer | ## Usage The **Drawer** component is ideal for use cases where content should be revealed in context without navigating to a new page. Common examples include: - Side navigation menus - Filters and settings panels - Detail views or contextual information **Do** - Use a Drawer to display contextual content or actions that stay relevant to the current page (e.g., filters, side forms, settings) - Allow the Drawer to be dismissed via clear and accessible interactions (e.g., close button, escape key, clicking outside, when enabled) - Customize the Drawer's width, height, and placement to match your layout and content needs - Keep transitions smooth and responsive, respecting the expected animation duration (e.g., 300ms) in the OVHcloud Design System - Maintain proper layering and z-index behavior - Use Drawers to maintain continuity of the user's workflow without breaking the page context **Don't** - Don't add more than one open Drawer at a time - Don't use excessively large Drawers that cover most or all of the page - Don't rely on Drawers for critical actions that require user confirmation, Modals are better suited for that - Don't leave Drawers open without a visible way to close them, always provide a clear exit path ### Best Practices in Context 1. **Drawer** ## Placement The **Drawer** can be positioned on any edge of the screen: - **Left/Right**: Covers 100% of the page height, with a default width of 320px and a maximum width of 100% - 3rem (48px) - **Top/Bottom**: Covers 100% of the page width, with a default height of 320px and a maximum height of 100vh - 3rem (48px) The **Drawer** is displayed above all page content but is positioned below the Modal in terms of layering, with or without backdrop, following the z-index hierarchy defined by OVHcloud Design System. This ensures consistent stacking behavior across components. By default, the OVHcloud Design System does not enforce whether the **Drawer** is fixed or scrollable. Integrators can configure this behavior based on their specific use case and requirements. Be careful the placement of the drawer can be broken if you create a new [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context). For example with a transform style or scale. ## Behavior The **Drawer** supports the following interactions: - Expansion: Triggered by interacting with a designated element, such as a button. - Collapsing: - By interacting with the same trigger used for expansion - By pressing the escape key - By clicking or moving the focus outside the Drawer (or clicking its backdrop), when `closeOnInteractOutside` is enabled (default with a backdrop) Animation: The **Drawer** slides into view with a smooth animation (default duration: 300ms). ## Backdrop The **Drawer** can display a backdrop behind it, using the same style as the Modal backdrop. Use it when the Drawer content requires the user's full attention and the rest of the page should not be used in the meantime (e.g., a side form to complete before going back to the page). Without backdrop, the page stays fully interactive, which suits contextual content such as filters or detail views. With a backdrop, the **Drawer** behaves as a modal: - Focus is trapped inside the Drawer - The rest of the page is inert and cannot be scrolled - Clicking on the backdrop closes the Drawer, unless `closeOnInteractOutside` is set to `false` ```tsx My drawer content ``` ## Variation The **Drawer** can slide in from the left, right, top, or bottom, depending on its configuration and the layout of the page. ## Navigation ### Focus Management When the **Drawer** is opened, focus automatically moves to the first focusable element inside. When the **Drawer** is closed while focus is inside it, or after its focused element was removed, focus returns to the trigger it was opened from, or, for a Drawer without trigger, to the element that was focused before it opened. A focus moved elsewhere in the page is left where it is. ### General Keyboard Shortcuts Pressing `Escape` closes the **Drawer**. Pressing `Tab` moves focus forward through the focusable elements inside the **Drawer**. Pressing `Shift` + `Tab` moves focus backward within the **Drawer**. With a backdrop, once the last focusable element is reached, focus does not leave the **Drawer** unless it is closed. Without backdrop, focus is not trapped and can leave the **Drawer** (e.g. with `Shift` + `Tab` from its first element), which then closes if `closeOnInteractOutside` is enabled. ## Accessibility To ensure the **Drawer** is fully accessible, correct ARIA attributes must be implemented. This ensures screen readers announce the **Drawer** properly and that keyboard users can interact with it effectively. ### Linking the Drawer title and content Ensure that assistive technologies announce the **Drawer** correctly using [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) or [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label), and [aria-describedby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-describedby). ```tsx The drawer content ``` ```tsx

My drawer

The drawer content

``` Screen readers will announce the sections referenced by the aria attributes. --- title: "Drawer" slug: drawer category: component type: technical-information version: 20.0.0 tokens: 634 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-drawer--technical-information.txt --- # Drawer ## Drawer | Property | Type | Required | Default | Description | |---|---|---|---|---| | `backdrop` | `boolean` | No | undefined | Whether a backdrop is displayed. With a backdrop, the drawer behaves as a modal: focus is trapped, the rest of the page is inert and its scroll is locked. | | `backdropStyle` | `CSSProperties` | No | undefined | Custom style applied to the drawer backdrop. Useful if you want to override the backdrop z-index. | | `closeOnEscape` | `boolean` | No | undefined | Whether to close the drawer when the escape key is pressed. | | `closeOnInteractOutside` | `boolean` | No | undefined | Whether to close the drawer when the user clicks or moves the focus outside of it. Defaults to true when a backdrop is displayed, false otherwise. | | `defaultOpen` | `boolean` | No | undefined | The initial open state of the drawer. Use when you don't need to control the open state of the drawer. | | `onOpenChange` | `(detail: DrawerOpenChangeDetail) => void` | No | undefined | Callback fired when the drawer open state changes. | | `open` | `boolean` | No | undefined | The controlled open state of the drawer. | | `positionerStyle` | `CSSProperties` | No | undefined | Custom style applied to the overlay positioner. | ## DrawerBody This component extends all the native `
` attributes. _No specific property._ ## DrawerContent This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `createPortal` | `boolean` | No | undefined | Whether the component should be rendered in the DOM close to the body tag. | | `position` | `DRAWER_POSITION` | No | undefined | The drawer position in the screen. | ## DrawerTrigger This component extends all the native ` My drawer content ``` ## Backdrop ```tsx My drawer content ``` ## Position ```tsx <> Top drawer content Left drawer content Right drawer content Bottom drawer content ``` ## Overlay Elements ```tsx This is the tooltip content ``` ## Controlled ```tsx { const [isOpen, setIsOpen] = useState(false); function onOpenChange({ open }: DrawerOpenChangeDetail) { setIsOpen(open); } function openDrawer() { setIsOpen(true); } return ( <> Content ); } ``` ## Accessibility Aria Labelled By ```tsx

My drawer

The drawer content

``` ## Accessibility Aria Label ```tsx The drawer content ``` ## Editable --- title: "Editable" slug: editable category: component type: overview version: 20.0.0 tokens: 309 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-editable.txt --- # Editable ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultEditing` | `boolean` | No | undefined | The initial editing state of the editable. Use when you don't need to control the editing state of the editable. | | `editing` | `boolean` | No | undefined | The controlled editing state of the editable. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `locale` | `'fr' | 'de' | 'en' | 'es' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `onCancel` | `() => void` | No | undefined | Callback fired when the cancel trigger is activated. | | `onEditChange` | `(detail: EditableEditingChangeDetail) => void` | No | undefined | Callback fired when the editing state changes. | | `onSubmit` | `() => void` | No | undefined | Callback fired when the submit trigger is activated. | ## Examples - Default - Controlled - Custom Actions - Complex Form Element ## Documentation pages - [Documentation](./react-components-editable--documentation.txt) - [Technical Information](./react-components-editable--technical-information.txt) - [Examples](./react-components-editable--examples.txt) --- title: "Editable" slug: editable category: component type: documentation version: 20.0.0 tokens: 769 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-editable--documentation.txt --- # Editable ## Overview The **Editable** component allows users to edit text directly in place. It replaces static text with an editable field, letting users quickly update content without opening a form or modal. | | | |---|---| | Name | Editable | | Also known as | Inline Editor | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/nrXo7riue1w773W2h4HGBS/ODS---UI-Kit?m=auto&node-id=14291-46529&t=rsFWlOhZe0TlF6Wd-1 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/editable | ## Usage The **Editable** component is used when users need to modify text directly in the interface, without disrupting their workflow. They are commonly used for: - Inline editing of cell values in a datagrid or table (e.g., a nickname) - Editable titles or headings (e.g., rename a dashboard) - Settings panels (e.g. configuration values, such as thresholds or labels) - Text snippets (e.g., section titles, captions) - Lists and todo items ### Dos & Don'ts **Do** - Use Editable when users need to edit values quickly and frequently. - Define a reasonable max length to prevent layout overflow. - Ensure editable content has a meaningful default or empty state. **Don't** - Remove visual cues that indicate editability. - Use Editable for long or complex form content. - Use Editable when changes must be reviewed or explicitly confirmed in a separate step. ### Best Practices in Context 1. **Editable** 2. **Preview / Editing field** 3. **Actions** Preview displays static text when not in edit mode while the field is visible only during edit mode. ## Behavior ### Edit Activation Users can enter edit mode through different triggers: - By click on the edit trigger - By double-click on the preview ### Editing When entering edit mode, the preview is replaced by a field containing the current value. Users can type in the field and update the current value. ### Submission The editable value should be committed when the user activates the submit trigger. ### Cancellation Activating the cancel trigger should discard the current changes and returns the component to its previous value. ### Empty If the current value is empty, an empty state should be displayed to indicate that no content has been defined yet. ## Navigation ### Focus Management When edit mode is entered, focus should moves to the expected field. Exiting edit mode returns focus according to the surrounding context. ### General Keyboard Shortcuts Pressing `Tab` moves focus forward to the next interactive element. Pressing `Shift` + `Tab` moves focus backward to the previous interactive element. Pressing `Enter` on the edit trigger activates edit mode. Pressing `Enter` on the submit trigger should commit the current value and exits edit mode. Pressing `Enter` on the cancel trigger should discard the current changes and exits edit mode. ## Accessibility Accessibility depends on the form elements used within **Editable**. Make sure inputs, triggers and custom actions follow standard accessibility rules. --- title: "Editable" slug: editable category: component type: technical-information version: 20.0.0 tokens: 484 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-editable--technical-information.txt --- # Editable ## Editable This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `defaultEditing` | `boolean` | No | undefined | The initial editing state of the editable. Use when you don't need to control the editing state of the editable. | | `editing` | `boolean` | No | undefined | The controlled editing state of the editable. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `locale` | `'fr' | 'de' | 'en' | 'es' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `onCancel` | `() => void` | No | undefined | Callback fired when the cancel trigger is activated. | | `onEditChange` | `(detail: EditableEditingChangeDetail) => void` | No | undefined | Callback fired when the editing state changes. | | `onSubmit` | `() => void` | No | undefined | Callback fired when the submit trigger is activated. | ## EditableActions This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `children` | `(props: object) => ReactNode` | No | undefined | Custom actions render function, that provides Editable current state. | ## EditableCancelTrigger _No specific property._ ## EditableDisplay This component extends all the native `
` attributes. _No specific property._ ## EditableDisplayEmpty This component extends all the native `` attributes. _No specific property._ ## EditableEditTrigger _No specific property._ ## EditableInput This component extends all the native `
` attributes. _No specific property._ ## EditableSubmitTrigger _No specific property._ ## Enums ### EDITABLE_I18N - `cancelButton` = `editable.actions.cancel.button` - `editButton` = `editable.actions.edit.button` - `submitButton` = `editable.actions.submit.button` --- title: "Editable" slug: editable category: component type: examples version: 20.0.0 tokens: 1129 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-editable--examples.txt --- # Editable ## Default ```tsx { const [value, setValue] = useState('Double click to edit'); const bufferValue = useRef(value); return ( bufferValue.current = value } onSubmit={ () => setValue(bufferValue.current) }> { value || Empty value } bufferValue.current = e.target.value } /> ); } ``` ## Controlled ```tsx { const [displayValue, setDisplayValue] = useState('Double click to edit'); const [value, setValue] = useState(displayValue); return ( setValue(displayValue) } onSubmit={ () => setDisplayValue(value) }> { displayValue || Empty value } setValue(e.target.value) } value={ value } /> ); } ``` ## Custom Actions ```tsx { const [value, setValue] = useState('Double click to edit'); const bufferValue = useRef(value); return ( bufferValue.current = value } onSubmit={ () => setValue(bufferValue.current) }> { value || Empty value } bufferValue.current = e.target.value } /> { ({ editing }) => ( editing ? <> : ) } ); } ``` ## Complex Form Element ```tsx { const [displayValue, setDisplayValue] = useState(''); const [accountValue, setAccountValue] = useState(''); const [domainValue, setDomainValue] = useState(''); function onCancel(): void { const [account, domain] = displayValue.split('@ovhcloud'); setAccountValue(account || ''); setDomainValue(domain || ''); } return ( setDisplayValue(`${accountValue}@ovhcloud${domainValue}`) }> { displayValue || Account name } setAccountValue(e.target.value) } pattern="^([a-zA-Z0-9]|([._\-](?![._\-])))*[a-zA-Z0-9]$" placeholder="Account name" value={ accountValue } /> @ovhcloud ); } ``` ## File Thumbnail --- title: "File Thumbnail" slug: file-thumbnail category: component type: overview version: 20.0.0 tokens: 299 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-thumbnail.txt --- # File Thumbnail ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `dismissible` | `boolean` | No | undefined | Whether the component holds a dismiss button. | | `error` | `string` | No | undefined | The file error message to display. | | `file` | `File` | Yes | undefined | The current File object. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for size formatting and the translation of the internal elements. | | `onFileRemove` | `(detail: FileThumbnailRemoveDetail) => void` | No | undefined | Callback fired when the file is removed. | | `progress` | `number` | No | undefined | The file upload progress. | ## Examples - Default - Progress - Disabled - Non Dismissible - Error ## Documentation pages - [Documentation](./react-components-file-thumbnail--documentation.txt) - [Technical Information](./react-components-file-thumbnail--technical-information.txt) - [Examples](./react-components-file-thumbnail--examples.txt) --- title: "File Thumbnail" slug: file-thumbnail category: component type: documentation version: 20.0.0 tokens: 778 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-thumbnail--documentation.txt --- # File Thumbnail ## Overview File Thumbnail component is a visual representation of an uploaded file, displaying a preview or a standalone icon alongside file metadata. It is designed to be used in file upload interfaces, attachment lists, or media libraries. | | | |---|---| | Name | FileThumbnail | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/branch/mwZtfuQ9nzv6fY0dfez4NZ/ODS---UI-Kit?node-id=18865-2253&t=5Qpq63EmcZsiF0hy-0 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/file-thumbnail | ## Usage File Thumbnail component is used to represent uploaded files in a compact format. It provides visual feedback about the file type, name, size, and upload time, while allowing users to remove the file. Common usages include: - File upload zones: display attached files after selection or upload. - Message composers: show file attachments before sending. - Media libraries: list uploaded documents, images, or assets. - Form fields: represent file inputs with selected file previews. ### Best Practices in Context 1. **FileThumbnail** TODO ## Behavior ### Content & Display Thumbnail / Preview: - Displays an image preview for supported image types. - Falls back to a generic file icon for non-image files. - The thumbnail image is resized and centered to avoid distortion. Fallback priority: - Image preview (if supported format and loads successfully). - Generic file icon (if type is unknown or unrecognized). File Metadata: - File name and extension, displayed with ellipsis truncation if too long; full name exposed via title attribute. - File size, displayed in human-readable format (e.g., 340 KB, 1.2 MB, 3.4 GB). Remove Action: - A remove button always visible. - Clicking remove should either: - Immediately removes the component with a brief undo toast. - Triggers an inline confirmation step before removal. ### States - Default: Thumbnail or fallback icon displayed with full metadata and remove button. - Read-only: Removal button disabled. - Loading: Progress Bar shown in place of file size while file uploads. - Error: Error icon shown with a short error message (e.g., "Preview unavailable" or "Upload failed"); file name and extension remain visible. ## Navigation The component is non-interactive by default, except for the remove button. The remove button receives keyboard focus via `Tab`. Pressing `Enter` or `Space` on the focused remove button triggers the remove action. Focus moves to the next thumbnail or the previous interactive element after removal. General Keyboard Shortcuts: - `Tab` : Moves focus to the remove button of the thumbnail. - `Enter` / `Space` : Activates the focused remove button. - `Shift` + `Tab` : Moves focus backward to the previous interactive element. ## Accessibility Each **File Thumbnail** must be wrapped in a `role="listitem"` element, and its parent container must have `role="list"` to allow screen readers to navigate between thumbnails. On remove, if a confirmation step is triggered, focus must move to the confirmation dialog or inline prompt. --- title: "File Thumbnail" slug: file-thumbnail category: component type: technical-information version: 20.0.0 tokens: 365 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-thumbnail--technical-information.txt --- # File Thumbnail ## FileThumbnail This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `dismissible` | `boolean` | No | undefined | Whether the component holds a dismiss button. | | `error` | `string` | No | undefined | The file error message to display. | | `file` | `File` | Yes | undefined | The current File object. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `locale` | `'de' | 'en' | 'es' | 'fr' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for size formatting and the translation of the internal elements. | | `onFileRemove` | `(detail: FileThumbnailRemoveDetail) => void` | No | undefined | Callback fired when the file is removed. | | `progress` | `number` | No | undefined | The file upload progress. | ## Enums ### FILE_THUMBNAIL_I18N - `cancelButton` = `fileThumbnail.file.cancel.button` - `deleteButton` = `fileThumbnail.file.delete.button` - `progressBar` = `fileThumbnail.file.progressBar` ## CSS Variables | Variable | Default value | |---|---| | `--ods-file-thumbnail-border-color` | `var(--ods-semantic-color-border-container)` | | `--ods-file-thumbnail-object-fit` | `contain` | | `--ods-file-thumbnail-preview-size` | `32px` | | `--ods-state-is-disabled-opacity` | `var(--ods-semantic-opacity-disabled)` | --- title: "File Thumbnail" slug: file-thumbnail category: component type: examples version: 20.0.0 tokens: 255 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-thumbnail--examples.txt --- # File Thumbnail ## Default ```tsx { const fakeFile = new File(['foo'], 'foo.txt', { type: 'text/plain' }); return ( ); } ``` ## Progress ```tsx { const fakeFile = new File(['foo'], 'foo.txt', { type: 'text/plain' }); return ( ); } ``` ## Disabled ```tsx { const fakeFile = new File(['foo'], 'foo.txt', { type: 'text/plain' }); return ( ); } ``` ## Non Dismissible ```tsx { const fakeFile = new File(['foo'], 'non-dismissible-file.txt', { type: 'text/plain' }); return ( ); } ``` ## Error ```tsx { const fakeFile = new File(['foo'], 'foo.txt', { type: 'text/plain' }); return ( ); } ``` ## File Upload --- title: "File Upload" slug: file-upload category: component type: overview version: 20.0.0 tokens: 563 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-upload.txt --- # File Upload _**File Upload** allows users to select one or more files to upload to a specific location._ ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `accept` | `string` | No | undefined | The accepted file types. | | `acceptedFileLabel` | `string` | No | undefined | Label describing the accepted file types. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `dropzoneLabel` | `string` | No | undefined | The dropzone label. | | `error` | `string` | No | undefined | The global error message to display. | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | | `locale` | `'fr' | 'de' | 'en' | 'es' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `maxFile` | `number` | No | undefined | The maximum number of files that can be selected. | | `maxFileLabel` | `string` | No | undefined | Label describing the maximum number of files that can be selected. | | `maxSize` | `number` | No | undefined | The maximum size of selectable files. | | `maxSizeLabel` | `string` | No | undefined | Label describing the maximum size of selectable files. | | `name` | `string` | No | undefined | The name of the form element. Useful for form submission. | | `onFileAccept` | `(detail: FileUploadAcceptDetail) => void` | No | undefined | Callback fired when a some files have been successfully added. | | `onFileReject` | `(detail: FileUploadRejectDetail) => void` | No | undefined | Callback fired when a some files have been rejected. | | `required` | `boolean` | No | undefined | Whether the component is required. | | `triggerLabel` | `string` | No | undefined | Upload button label. | | `variant` | `'default' | 'compact'` | No | undefined | The variant preset to use. | ## Examples - Default - Compact - Disabled - Custom Labels - Accept - Max File - Max Size - Upload - In Form Field - Accessibility File Button - Accessibility Form Field ## Documentation pages - [Documentation](./react-components-file-upload--documentation.txt) - [Technical Information](./react-components-file-upload--technical-information.txt) - [Examples](./react-components-file-upload--examples.txt) --- title: "File Upload" slug: file-upload category: component type: documentation version: 20.0.0 tokens: 1908 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-upload--documentation.txt --- # File Upload _**File Upload** allows users to select one or more files to upload to a specific location._ ## Overview Form Guidelines] } figmaLink="https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=55-24358" githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/file-upload" name="File Upload"> The **File Upload** component is used to enable users to upload files to a server or application. It provides a way to browse, select, and upload files, and is accompanied by progress indicators and feedback messages to guide users through the process. | | | |---|---| | Name | undefined | | Also known as | File input, File uploader, Dropzone | ## Usage Use the **File Upload** component when you need users to submit files, such as documents, images, or other data. Common use cases include form submissions, profile picture updates, and document management systems. ### Dos & Don'ts **Do** - Use a single File Upload component per context when allowing users to upload multiple files on the same page - Clearly communicate constraints such as file type, size limits, or max number of files - Use short and clear success message once the upload is complete - Ensure error messages are specific and actionable (e.g., “File exceeds 5MB limit” instead of a generic “Upload failed”) **Don't** - Don't place the File Upload component inside a modal unless absolutely necessary - Don't allow file uploads without providing feedback or confirmation - Don't assume users know upload limitations. Make restrictions explicit ### Best Practices in Context 1. **File Upload** 2. **Description** - optional (file limitations) 3. **Dropzone** 4. **Upload button** 5. **Uploaded files zone** 6. **Delete button** ## Placement **File Upload** component can be part of a complex form, or displayed as a standalone. **File Upload** has an automatic default width, based on its content. ## Behavior ### Selecting files When selecting the "Browse" Button, the native file selection popup opens to retrieve the needed file to upload. ### Drag & Drop Users can drag & drop a file, the drop zone being the whole **File Upload** component. ### Uploading files When a file upload is in progress, the file name and its size (if available) are displayed. A Spinner is displayed to indicate the file is uploading. It remains visible as long as the file uploading is not finished yet. The uploading progress percentage can be indicated next to the file name. A close icon Button is displayed as soon as a file upload is in progress. It is displayed as long as the user does not interrupt the upload or removes an already uploaded file. ### Upload complete #### With success The Spinner is replaced with the file icon, the file name and the icon turn green, as soon as a file has been uploaded, meaning the upload is successful and complete. #### With error If the uploading of a file went wrong, the Spinner is replaced with an error icon, and the file name and the icon turn red. A specific `error` message may be displayed below the uploaded file. The user is still able to upload another file but the file in error will remain in error until user removes it. Depending on the error, the global component can be displayed in an error state. ### Extra behavior #### Global configuration / error Number of files, maximum sizes and expected formats can be set globally inside the component. A global `error` message is displayed when: * Wrong file format has been uploaded * Maximum file size exceeded * Maximum number of files exceeded The global component is displayed in an error state in this situation. #### Disabled When **File Upload** is disabled, user cannot interact with the Button and drag & drop feature is not available. #### Cancel a file upload in progress A click or press on the `close` icon Button interrupts the upload (or cancel an uploaded file). When the upload is canceled, the file upload is removed and the **File Upload** component returns to its default state, except for any other files in the queue. In case some other files have already been uploaded, and the user cancels an uploading file, the next one will take its place in the queue and so on. #### Remove an already uploaded file An already uploaded file can be removed by clicking or pressing the `close` icon Button anytime. Same as cancelling a file while it is uploading, if several files have already been uploaded and the user cancels an uploading file, the next one will take its place in the queue and so on. ## Navigation ### Focus Management When tabbing through the page, the **File Upload** trigger button receives focus as part of the natural tab order. If one or more files are being uploaded or already uploaded, each close icon button becomes focusable in the tab order, in the order files were added. If the component is disabled, it cannot receive focus and no interaction is possible. The drag-and-drop area does not receive focus but accepts dropped files while the component is enabled. ### General Keyboard Shortcuts Pressing `Tab` moves focus forward through the **File Upload** trigger button and all available close icon buttons. Pressing `Shift` + `Tab` moves focus backward through these same elements. Pressing `Enter` or `Space` while the trigger button is focused opens the native file selection dialog. Pressing `Enter` or `Space` on a close icon button cancels an upload in progress or removes the corresponding uploaded file from the list. ## Accessibility To ensure proper accessibility, the **File Upload** component must be correctly labeled and provide meaningful context when interactive elements (such as icon buttons) are used. ### Always provide an explicit label Every **File Upload** must have a clear and explicit label to ensure that users (especially screen reader users) understand its purpose, using either **FormField** or a native label tag. ```tsx { const [files, setFiles] = useState([]); return ( Files: setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` Screen readers will announce the label, the field and its content. ### Labeling cancel/delete Button The `Cancel` and `Delete` file buttons have to be explicit by adding context about their action and the file name. ```tsx { const [files, setFiles] = useState([]); return ( setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` Screen readers will announce the action and the file name. --- title: "File Upload" slug: file-upload category: component type: technical-information version: 20.0.0 tokens: 862 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-upload--technical-information.txt --- # File Upload ## FileUpload This component extends all the native `
` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `accept` | `string` | No | undefined | The accepted file types. | | `acceptedFileLabel` | `string` | No | undefined | Label describing the accepted file types. | | `disabled` | `boolean` | No | undefined | Whether the component is disabled. | | `dropzoneLabel` | `string` | No | undefined | The dropzone label. | | `error` | `string` | No | undefined | The global error message to display. | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | | `locale` | `'fr' | 'de' | 'en' | 'es' | 'it' | 'nl' | 'pl' | 'pt'` | No | undefined | The locale used for the translation of the internal elements. | | `maxFile` | `number` | No | undefined | The maximum number of files that can be selected. | | `maxFileLabel` | `string` | No | undefined | Label describing the maximum number of files that can be selected. | | `maxSize` | `number` | No | undefined | The maximum size of selectable files. | | `maxSizeLabel` | `string` | No | undefined | Label describing the maximum size of selectable files. | | `name` | `string` | No | undefined | The name of the form element. Useful for form submission. | | `onFileAccept` | `(detail: FileUploadAcceptDetail) => void` | No | undefined | Callback fired when a some files have been successfully added. | | `onFileReject` | `(detail: FileUploadRejectDetail) => void` | No | undefined | Callback fired when a some files have been rejected. | | `required` | `boolean` | No | undefined | Whether the component is required. | | `triggerLabel` | `string` | No | undefined | Upload button label. | | `variant` | `'default' | 'compact'` | No | undefined | The variant preset to use. | ## FileUploadItem This component extends all the native `
  • ` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `error` | `string` | No | undefined | The file error message to display. | | `file` | `File` | Yes | undefined | The current File object. | | `i18n` | `Partial` | No | undefined | Internal translations override. | | `progress` | `number` | No | undefined | The file upload progress. | ## FileUploadList This component extends all the native `
      ` attributes. _No specific property._ ## Enums ### FILE_REJECTION_CAUSE - `invalidFile` = `invalid-file` - `maxFileReached` = `max-file-reached` - `sizeTooLarge` = `size-too-large` - `unknownError` = `unknown-error` - `wrongFormat` = `wrong-format` ### FILE_UPLOAD_I18N - `cancelButton` = `fileUpload.file.cancel.button` - `deleteButton` = `fileUpload.file.delete.button` - `progressBar` = `fileUpload.file.progressBar` ### FILE_UPLOAD_VARIANT - `compact` = `compact` - `default` = `default` ## CSS Variables | Variable | Default value | |---|---| | `--ods-state-is-disabled-opacity` | `var(--ods-semantic-opacity-disabled)` | | `--ods-file-upload-item-background-color-hover` | `var(--ods-semantic-color-interaction-highlight)` | | `--ods-file-upload-item-border-radius` | `calc(var(--ods-semantic-size-radius-container) / 2)` | | `--ods-file-upload-item-text-color-critical-hover` | `var(--ods-semantic-color-content-critical)` | | `--ods-file-upload-padding-horizontal` | `var(--ods-semantic-size-space-inset-inline)` | | `--ods-file-upload-padding-vertical` | `var(--ods-semantic-size-space-inset-block)` | --- title: "File Upload" slug: file-upload category: component type: examples version: 20.0.0 tokens: 1927 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-file-upload--examples.txt --- # File Upload ## Default ```tsx { const [files, setFiles] = useState([]); return ( setFiles(files) }> { files.map((file: File, idx) => ( )) } ); } ``` ## Compact ```tsx { const [files, setFiles] = useState([]); return ( setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` ## Disabled ```tsx ``` ## Custom Labels ```tsx { const [files, setFiles] = useState([]); return ( setFiles(files) } triggerLabel="Parcourir les fichiers" variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` ## Accept ```tsx { const [error, setError] = useState(''); const [files, setFiles] = useState([]); function onAccept({ files }: FileUploadAcceptDetail): void { setFiles(files); setError(''); } function onReject({ files }: FileUploadRejectDetail): void { setError(files.length ? 'File(s) not of the expected format' : ''); } return ( { files.map((file: File, idx) => ( )) } ); } ``` ## Max File ```tsx { const [error, setError] = useState(''); const [files, setFiles] = useState([]); function onAccept({ files }: FileUploadAcceptDetail): void { setFiles(files); setError(''); } function onReject({ files }: FileUploadRejectDetail): void { setError(files.length ? 'Too many files' : ''); } return ( { files.map((file: File, idx) => ( )) } ); } ``` ## Max Size ```tsx { const [error, setError] = useState(''); const [files, setFiles] = useState([]); function onAccept({ files }: FileUploadAcceptDetail): void { setFiles(files); setError(''); } function onReject({ files }: FileUploadRejectDetail): void { setError(files.length ? 'File(s) too large' : ''); } return ( { files.map((file: File, idx) => ( )) } ); } ``` ## Upload ```tsx { type MyFile = File & { error?: string, progress?: number, } const [files, setFiles] = useState([]); useEffect(() => { files.forEach((file) => { if (!file.progress) { uploadFile(file); } }); }, [files]); function uploadFile(file: MyFile): void { const intervalId = setInterval(() => { setFiles((files) => files.map((f) => { if (f.name === file.name) { f.progress = (f.progress || 0) + Math.floor(Math.random() * 10 + 1); if (f.progress >= 100) { clearInterval(intervalId); } } return f; })); }, 100); } return ( setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file, idx) => ( )) } ); } ``` ## In Form Field ```tsx { const [files, setFiles] = useState([]); return ( Files: setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` ## Accessibility File Button ```tsx { const [files, setFiles] = useState([]); return ( setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` ## Accessibility Form Field ```tsx { const [files, setFiles] = useState([]); return ( Files: setFiles(files) } variant={ FILE_UPLOAD_VARIANT.compact }> { files.map((file: File, idx) => ( )) } ); } ``` ## Form Field --- title: "Form Field" slug: form-field category: component type: overview version: 20.0.0 tokens: 194 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-form-field.txt --- # Form Field _A **Form Field** component is used to wrap several form components with logic, visual hints and additional styling_ ## Props | Property | Type | Required | Default | Description | |---|---|---|---|---| | `id` | `string` | No | undefined | The id given to the wrapped field, generated when omitted. An id set on the field itself takes precedence. | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | ## Examples - Default - Label - Label Sub Label - Helper - Error - Accessibility Label ## Documentation pages - [Documentation](./react-components-form-field--documentation.txt) - [Technical Information](./react-components-form-field--technical-information.txt) - [Examples](./react-components-form-field--examples.txt) --- title: "Form Field" slug: form-field category: component type: documentation version: 20.0.0 tokens: 990 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-form-field--documentation.txt --- # Form Field _A **Form Field** component is used to wrap several form components with logic, visual hints and additional styling_ ## Overview Form Guidelines] } figmaLink="https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=172-11996" githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/form-field" name="Form Field"> A **Form Field** is based on a single form element or group components as a whole that are decorated with additional text to handle specific types of information, like a Password field for example. | | | |---|---| | Name | undefined | | Also known as | Form Control | ## Usage A **Form Field** is used to wrap a field that can be customized with some additional information about this field. Additional information (label, placeholder, helper message) provides hint and help to users, so that they can easily understand what is required from them in a form. Users will also type or enter information in the expected format and avoid mistakes. ### Dos & Don'ts **Do** - Use Form Field to wrap form inputs with a clear structure, including a label, optional helper text, or extra information - Group related fields using multiple Form Fields to improve clarity and scannability - Include helper messages to guide users on expected input formats or constraints (e.g., password requirements) - Use error message to provide feedback after user interaction **Don't** - Don't place interactive elements like links or buttons inside the label - Don't rely on an asterisk alone to indicate required fields. Prefer explicit helper text or label - Overuse content related Form Fields with top aligned label in one group since it requires quite vertical space: split into smaller groups - Don't use Form Field when there's no input or interaction expected. It is meant for form inputs, not static content ### Best Practices in Context 1. **Form Field** 2. **Label** - optional 3. **Form element** 4. **Helper message** - optional 5. **Error message** - optional 6. **Hint text** - optional ## Placement A **Form Field** can be used everywhere in a page where there is a form and users may need help to fill in this form. ## Behavior A **Form Field** can react to validation states, such as error, often by visually updating elements like the border or text indicators. Helper text and error messages can be displayed freely around the field component, depending on the design or functional needs. ## Navigation The **Form Field** component itself is not focusable and does not receive keyboard focus. Only the interactive inner component it wraps, such as an Input, Password, Select, or other form element, can receive focus. Focus behavior and keyboard navigation are determined by the specific form element used within the **Form Field**. ## Accessibility The **Form Field** component handles by itself the accessibility requirements by using its internal components. ```tsx Login: Username or email address ``` Screen readers will announce the label, the field, its content and the helper text. ### Field id You don't need to set any id: the **Form Field** gives one to the field it wraps, then links the label, the helper text and the error message to it. When you need a specific id (for an anchor, an end-to-end test or an external reference), set it either on the **Form Field** or directly on the field. An id set on the field takes precedence, and the label follows it: ```tsx Email: {/* The label targets "email" */} ``` **Radio Group** and **Range** have no single element for the label to target: the label names the radio group, or each thumb of the range, instead. --- title: "Form Field" slug: form-field category: component type: technical-information version: 20.0.0 tokens: 289 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-form-field--technical-information.txt --- # Form Field ## FormField This component extends all the native `
      ` attributes. | Property | Type | Required | Default | Description | |---|---|---|---|---| | `id` | `string` | No | undefined | The id given to the wrapped field, generated when omitted. An id set on the field itself takes precedence. | | `invalid` | `boolean` | No | undefined | Whether the component is in error state. | ## FormFieldError This component extends all the native `` attributes. _No specific property._ ## FormFieldHelper This component extends all the native `` attributes. _No specific property._ ## FormFieldLabel This component extends all the native `