diff --git a/src/components/FormControl/FormControl.stories.tsx b/src/components/FormControl/FormControl.stories.tsx
index e438b2d9..278e30d8 100644
--- a/src/components/FormControl/FormControl.stories.tsx
+++ b/src/components/FormControl/FormControl.stories.tsx
@@ -41,6 +41,7 @@ export const API_1: Story = () => {
const [disabled, setDisabled] = useState(false)
const [error, setError] = useState(false)
const [valid, setValid] = useState(false)
+ const [native, setNative] = useState(false)
const rotate = rotateCheckedState(setRequired)
@@ -67,6 +68,11 @@ export const API_1: Story = () => {
onCheckedChange={setValid}
label="Valid"
>
+
@@ -77,6 +83,7 @@ export const API_1: Story = () => {
error={error}
valid={valid}
disabled={disabled}
+ native={native}
required={required === 'indeterminate' ? undefined : required}
/>
{
)
}
+/**
+ * The `native` prop can be added to allow the use of the native html `:invalid` and `:valid` pseudo-classes.
+ *
+ * This is not the default as can have negative user experience when required forms show initial error.
+ *
+ * This is useful for styling the inputs when using the native html validation attributes.
+ * The is added for checkbox, radio, and select inputs too but uses the :has selector which has limited support.
+ */
+export const Native: Story = () => {
+ return (
+
+ )
+}
+
+/**
+ * Behavioural test/demo. Use the checkboxes to add these properties to all form elements.
+ */
export const Controls: Story = () => {
const [required, setRequired] = useState('indeterminate')
const [disabled, setDisabled] = useState(false)
const [error, setError] = useState(false)
const [valid, setValid] = useState(false)
+ const [native, setNative] = useState(false)
const rotate = rotateCheckedState(setRequired)
@@ -212,6 +263,7 @@ export const Controls: Story = () => {
valid,
disabled,
required: required === 'indeterminate' ? undefined : required,
+ native,
}
return (
@@ -237,6 +289,11 @@ export const Controls: Story = () => {
onCheckedChange={setValid}
label="Valid"
>
+