Components
ValidationMessage
ValidationMessage is used to display feedback related to the validation of user input, such as error messages or warnings in forms.
React
Press Enter to start editing
const PreviewEn = () => { return <ValidationMessage>This is a validation message.</ValidationMessage>; }; render(<PreviewEn />)
- asChild
- Description
Change the default rendered element for the one passed as a child, merging their props and behavior.
- Type
boolean- Default
false
| Name | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Change the default rendered element for the one passed as a child, merging their props and behavior. |
Usage
Examples
All colors
You switch between colors by setting the data-color attribute.
This changes the icon.
React
Press Enter to start editing
const AllColorsEn = () => { return ( <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}> <ValidationMessage data-color='danger'> This is an error message. </ValidationMessage> <ValidationMessage data-color='success'> This is a success message. </ValidationMessage> <ValidationMessage data-color='info'> This is an informational message. </ValidationMessage> <ValidationMessage data-color='warning'> This is a warning message. </ValidationMessage> </div> ); }; render(<AllColorsEn />)
CSS variables and data attributes
| Name | Value |
|---|---|
| --dsc-validation-message-icon-url | url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M7.74 2.47a.75.75 0 0 1 .53-.22h7.46a.75.75 0 0 1 .53.22l5.27 5.27c.14.14.22.33.22.53v7.46a.75.75 0 0 1-.22.53l-5.27 5.27a.75.75 0 0 1-.53.22H8.27a.75.75 0 0 1-.53-.22l-5.27-5.27a.75.75 0 0 1-.22-.53V8.27a.75.75 0 0 1 .22-.53zm1.29 5.5a.75.75 0 0 0-1.06 1.06L10.94 12l-2.97 2.97a.75.75 0 1 0 1.06 1.06L12 13.06l2.97 2.97a.75.75 0 1 0 1.06-1.06L13.06 12l2.97-2.97a.75.75 0 0 0-1.06-1.06L12 10.94z'/%3E%3C/svg%3E") |
| --dsc-validation-message-icon-size | var(--ds-size-7) |
| --dsc-validation-message-spacing | var(--ds-size-2) |
| --dsc-validation-message-color | var(--ds-color-danger-text-subtle) |
No relevant data attributes found.
Edit this page on github.com (opens in a new tab)