Skip to content

Commit 53749c3

Browse files
Read from --default-outline-width (#16469)
Closes tailwindlabs/tailwindcss.com#2073 This ensures that we can customize `outline` via `--default-outline-width` just like `ring`, `border`, and other utilities. ## Test plan Added unit tests for `--default-outline-width` and `--default-ring-width`
1 parent 7326f64 commit 53749c3

File tree

3 files changed

+116
-1
lines changed

3 files changed

+116
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Fix sorting numeric utilities when they have different magnitudes ([#16414](https://github.com/tailwindlabs/tailwindcss/pull/16414))
1818
- Show suggestions for fractions in IntelliSense ([#16353](https://github.com/tailwindlabs/tailwindcss/pull/16353))
1919
- Don’t replace `_` in suggested theme keys ([#16433](https://github.com/tailwindlabs/tailwindcss/pull/16433))
20+
- Ensure `--default-outline-width` can be used to change the `outline-width` value of the `outline` utility
2021

2122
## [4.0.6] - 2025-02-10
2223

packages/tailwindcss/src/utilities.test.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14736,6 +14736,32 @@ test('outline', async () => {
1473614736
initial-value: solid;
1473714737
}"
1473814738
`)
14739+
expect(
14740+
await compileCss(
14741+
css`
14742+
@theme {
14743+
--default-outline-width: 2px;
14744+
}
14745+
@tailwind utilities;
14746+
`,
14747+
['outline'],
14748+
),
14749+
).toMatchInlineSnapshot(`
14750+
":root, :host {
14751+
--default-outline-width: 2px;
14752+
}
14753+
14754+
.outline {
14755+
outline-style: var(--tw-outline-style);
14756+
outline-width: 2px;
14757+
}
14758+
14759+
@property --tw-outline-style {
14760+
syntax: "*";
14761+
inherits: false;
14762+
initial-value: solid;
14763+
}"
14764+
`)
1473914765
expect(
1474014766
await run([
1474114767
'-outline',
@@ -15849,6 +15875,93 @@ test('ring', async () => {
1584915875
initial-value: 0 0 #0000;
1585015876
}"
1585115877
`)
15878+
expect(
15879+
await compileCss(
15880+
css`
15881+
@theme {
15882+
--default-ring-width: 2px;
15883+
}
15884+
@tailwind utilities;
15885+
`,
15886+
['ring'],
15887+
),
15888+
).toMatchInlineSnapshot(`
15889+
":root, :host {
15890+
--default-ring-width: 2px;
15891+
}
15892+
15893+
.ring {
15894+
--tw-ring-shadow: var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentColor);
15895+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
15896+
}
15897+
15898+
@property --tw-shadow {
15899+
syntax: "*";
15900+
inherits: false;
15901+
initial-value: 0 0 #0000;
15902+
}
15903+
15904+
@property --tw-shadow-color {
15905+
syntax: "*";
15906+
inherits: false
15907+
}
15908+
15909+
@property --tw-inset-shadow {
15910+
syntax: "*";
15911+
inherits: false;
15912+
initial-value: 0 0 #0000;
15913+
}
15914+
15915+
@property --tw-inset-shadow-color {
15916+
syntax: "*";
15917+
inherits: false
15918+
}
15919+
15920+
@property --tw-ring-color {
15921+
syntax: "*";
15922+
inherits: false
15923+
}
15924+
15925+
@property --tw-ring-shadow {
15926+
syntax: "*";
15927+
inherits: false;
15928+
initial-value: 0 0 #0000;
15929+
}
15930+
15931+
@property --tw-inset-ring-color {
15932+
syntax: "*";
15933+
inherits: false
15934+
}
15935+
15936+
@property --tw-inset-ring-shadow {
15937+
syntax: "*";
15938+
inherits: false;
15939+
initial-value: 0 0 #0000;
15940+
}
15941+
15942+
@property --tw-ring-inset {
15943+
syntax: "*";
15944+
inherits: false
15945+
}
15946+
15947+
@property --tw-ring-offset-width {
15948+
syntax: "<length>";
15949+
inherits: false;
15950+
initial-value: 0;
15951+
}
15952+
15953+
@property --tw-ring-offset-color {
15954+
syntax: "*";
15955+
inherits: false;
15956+
initial-value: #fff;
15957+
}
15958+
15959+
@property --tw-ring-offset-shadow {
15960+
syntax: "*";
15961+
inherits: false;
15962+
initial-value: 0 0 #0000;
15963+
}"
15964+
`)
1585215965
expect(
1585315966
await run([
1585415967
// ring color

packages/tailwindcss/src/utilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3928,10 +3928,11 @@ export function createUtilities(theme: Theme) {
39283928
utilities.functional('outline', (candidate) => {
39293929
if (candidate.value === null) {
39303930
if (candidate.modifier) return
3931+
let value = theme.get(['--default-outline-width']) ?? '1px'
39313932
return [
39323933
outlineProperties(),
39333934
decl('outline-style', 'var(--tw-outline-style)'),
3934-
decl('outline-width', '1px'),
3935+
decl('outline-width', value),
39353936
]
39363937
}
39373938

0 commit comments

Comments
 (0)