Skip to content

Commit 673d2df

Browse files
authored
style(input): add border on hover (#4125)
1 parent b878ce3 commit 673d2df

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

.changeset/rude-snails-report.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@digdir/designsystemet-css": patch
3+
---
4+
5+
**input**: Add outline on `:hover` when not `:focus-visible`, `:disabled` or `[readonly]`. This adds a few new CSS variables:
6+
- `--dsc-input-outline-color--hover`
7+
- `--dsc-input-outline-color--toggle--hover`
8+
- `--dsc-input-outline-width--hover`
9+
- `--dsc-input-outline-style--hover`

packages/css/src/input.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
--dsc-input-border-style: solid;
1515
--dsc-input-border-width--toggle: max(var(--ds-border-width-default), calc(var(--ds-size-1) / 2)); /* Allow border-width to grow with font-size */
1616
--dsc-input-border-width: var(--ds-border-width-default);
17+
/* hover */
18+
--dsc-input-outline-color--hover: var(--ds-color-neutral-border-default);
19+
--dsc-input-outline-color--toggle--hover: var(--dsc-input-accent-color);
20+
--dsc-input-outline-width--hover: var(--ds-border-width-default);
21+
--dsc-input-outline-style--hover: solid;
1722
/* Color */
1823
--dsc-input-color--readonly: var(--ds-color-neutral-text-default);
1924
--dsc-input-color: var(--ds-color-neutral-text-default);
@@ -51,6 +56,20 @@
5156
@composes ds-print-preserve from './base.css';
5257
@composes ds-focus from './base.css';
5358

59+
&:not(:focus-visible, :disabled, [readonly]):hover {
60+
outline-color: var(--dsc-input-outline-color--hover);
61+
outline-width: var(--dsc-input-outline-width--hover);
62+
outline-style: var(--dsc-input-outline-style--hover);
63+
64+
&:is(:checked, :indeterminate:where([type='checkbox'])):not([aria-invalid='true']) {
65+
outline-color: var(--dsc-input-outline-color--toggle--hover);
66+
}
67+
68+
&:is([aria-invalid='true']) {
69+
outline-color: var(--dsc-input-accent-color--invalid);
70+
}
71+
}
72+
5473
@media (forced-colors: active) {
5574
border-color: ButtonText;
5675
background-color: Canvas;

0 commit comments

Comments
 (0)