Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added new `bg-{position,size}-*` utilities for arbitrary values ([#17432](https://github.com/tailwindlabs/tailwindcss/pull/17432))
- Added new `shadow-*/{alpha}`, `inset-shadow-*/{alpha}`, and `text-shadow-*/{alpha}` utilities to control shadow opacity ([#17398](https://github.com/tailwindlabs/tailwindcss/pull/17398))
- Added new `object-{top,bottom}-{left,right}` utilities ([#17437](https://github.com/tailwindlabs/tailwindcss/pull/17437))
- Added new `drop-shadow-{color}` utilities ([#17434](https://github.com/tailwindlabs/tailwindcss/pull/17434))
- Added new `drop-shadow-*/{alpha}` utilities to control drop shadow opacity ([#17434](https://github.com/tailwindlabs/tailwindcss/pull/17434))

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3984,8 +3984,74 @@ exports[`getClassList 1`] = `
"divide-y-4",
"divide-y-8",
"divide-y-reverse",
"drop-shadow-current",
"drop-shadow-current/0",
"drop-shadow-current/5",
"drop-shadow-current/10",
"drop-shadow-current/15",
"drop-shadow-current/20",
"drop-shadow-current/25",
"drop-shadow-current/30",
"drop-shadow-current/35",
"drop-shadow-current/40",
"drop-shadow-current/45",
"drop-shadow-current/50",
"drop-shadow-current/55",
"drop-shadow-current/60",
"drop-shadow-current/65",
"drop-shadow-current/70",
"drop-shadow-current/75",
"drop-shadow-current/80",
"drop-shadow-current/85",
"drop-shadow-current/90",
"drop-shadow-current/95",
"drop-shadow-current/100",
"drop-shadow-inherit",
"drop-shadow-inherit/0",
"drop-shadow-inherit/5",
"drop-shadow-inherit/10",
"drop-shadow-inherit/15",
"drop-shadow-inherit/20",
"drop-shadow-inherit/25",
"drop-shadow-inherit/30",
"drop-shadow-inherit/35",
"drop-shadow-inherit/40",
"drop-shadow-inherit/45",
"drop-shadow-inherit/50",
"drop-shadow-inherit/55",
"drop-shadow-inherit/60",
"drop-shadow-inherit/65",
"drop-shadow-inherit/70",
"drop-shadow-inherit/75",
"drop-shadow-inherit/80",
"drop-shadow-inherit/85",
"drop-shadow-inherit/90",
"drop-shadow-inherit/95",
"drop-shadow-inherit/100",
"drop-shadow-none",
"drop-shadow-sm",
"drop-shadow-transparent",
"drop-shadow-transparent/0",
"drop-shadow-transparent/5",
"drop-shadow-transparent/10",
"drop-shadow-transparent/15",
"drop-shadow-transparent/20",
"drop-shadow-transparent/25",
"drop-shadow-transparent/30",
"drop-shadow-transparent/35",
"drop-shadow-transparent/40",
"drop-shadow-transparent/45",
"drop-shadow-transparent/50",
"drop-shadow-transparent/55",
"drop-shadow-transparent/60",
"drop-shadow-transparent/65",
"drop-shadow-transparent/70",
"drop-shadow-transparent/75",
"drop-shadow-transparent/80",
"drop-shadow-transparent/85",
"drop-shadow-transparent/90",
"drop-shadow-transparent/95",
"drop-shadow-transparent/100",
"duration-75",
"duration-100",
"duration-150",
Expand Down
52 changes: 51 additions & 1 deletion packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20362,6 +20362,7 @@ test('filter', async () => {
css`
@theme {
--blur-xl: 24px;
--color-red-500: #ef4444;
--drop-shadow: 0 1px 1px rgb(0 0 0 / 0.05);
--drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);
}
Expand Down Expand Up @@ -20389,8 +20390,11 @@ test('filter', async () => {
'invert-0',
'invert-[var(--value)]',
'drop-shadow',
'drop-shadow/25',
'drop-shadow-xl',
'drop-shadow-[0_0_red]',
'drop-shadow-red-500',
'drop-shadow-red-500/50',
'saturate-0',
'saturate-[1.75]',
'saturate-[var(--value)]',
Expand Down Expand Up @@ -20420,6 +20424,7 @@ test('filter', async () => {

:root, :host {
--blur-xl: 24px;
--color-red-500: #ef4444;
--drop-shadow: 0 1px 1px #0000000d;
--drop-shadow-xl: 0 9px 7px #0000001a;
}
Expand Down Expand Up @@ -20459,21 +20464,41 @@ test('filter', async () => {
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

.drop-shadow\\/25 {
--tw-drop-shadow-alpha: 25%;
--tw-drop-shadow-size: drop-shadow(0 1px 1px var(--tw-drop-shadow-color, oklab(0% 0 0 / .25)));
--tw-drop-shadow: drop-shadow(var(--drop-shadow));
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

.drop-shadow {
--tw-drop-shadow-size: drop-shadow(0 1px 1px var(--tw-drop-shadow-color, #0000000d));
--tw-drop-shadow: drop-shadow(var(--drop-shadow));
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

.drop-shadow-\\[0_0_red\\] {
--tw-drop-shadow: drop-shadow(0 0 red);
--tw-drop-shadow-size: drop-shadow(0 0 var(--tw-drop-shadow-color, red));
--tw-drop-shadow: var(--tw-drop-shadow-size);
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

.drop-shadow-xl {
--tw-drop-shadow-size: drop-shadow(0 9px 7px var(--tw-drop-shadow-color, #0000001a));
--tw-drop-shadow: drop-shadow(var(--drop-shadow-xl));
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
}

.drop-shadow-red-500 {
--tw-drop-shadow-color: color-mix(in oklab, var(--color-red-500) var(--tw-drop-shadow-alpha), transparent);
--tw-drop-shadow: var(--tw-drop-shadow-size);
}

.drop-shadow-red-500\\/50 {
--tw-drop-shadow-color: color-mix(in oklab, color-mix(in oklab, var(--color-red-500) 50%, transparent) var(--tw-drop-shadow-alpha), transparent);
--tw-drop-shadow: var(--tw-drop-shadow-size);
}

.grayscale {
--tw-grayscale: grayscale(100%);
filter: var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, );
Expand Down Expand Up @@ -20619,6 +20644,22 @@ test('filter', async () => {
@property --tw-drop-shadow {
syntax: "*";
inherits: false
}

@property --tw-drop-shadow-color {
syntax: "*";
inherits: false
}

@property --tw-drop-shadow-alpha {
syntax: "<percentage>";
inherits: false;
initial-value: 100%;
}

@property --tw-drop-shadow-size {
syntax: "*";
inherits: false
}"
`)
expect(
Expand Down Expand Up @@ -20650,6 +20691,15 @@ test('filter', async () => {
'invert-unknown',
'-drop-shadow-xl',
'-drop-shadow-[0_0_red]',

'drop-shadow/foo',
'-drop-shadow/foo',
'-drop-shadow/25',
'-drop-shadow-red-500',
'drop-shadow-red-500/foo',
'-drop-shadow-red-500/foo',
'-drop-shadow-red-500/50',

'-saturate-0',
'saturate--5',
'-saturate-[1.75]',
Expand Down
169 changes: 157 additions & 12 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3926,6 +3926,9 @@ export function createUtilities(theme: Theme) {
property('--tw-saturate'),
property('--tw-sepia'),
property('--tw-drop-shadow'),
property('--tw-drop-shadow-color'),
property('--tw-drop-shadow-alpha', '100%', '<percentage>'),
property('--tw-drop-shadow-size'),
])
}

Expand Down Expand Up @@ -4318,20 +4321,162 @@ export function createUtilities(theme: Theme) {
['--tw-drop-shadow', ' '],
['filter', cssFilterValue],
])
functionalUtility('drop-shadow', {
themeKeys: ['--drop-shadow'],
handle: (value) => [
filterProperties(),
decl(
'--tw-drop-shadow',
segment(value, ',')
.map((v) => `drop-shadow(${v})`)
.join(' '),
),
decl('filter', cssFilterValue),
],

utilities.functional('drop-shadow', (candidate) => {
let alpha: string | undefined

if (candidate.modifier) {
if (candidate.modifier.kind === 'arbitrary') {
alpha = candidate.modifier.value
} else {
if (isPositiveInteger(candidate.modifier.value)) {
alpha = `${candidate.modifier.value}%`
}
}
}

if (!candidate.value) {
let value = theme.get(['--drop-shadow'])
if (value === null) return

return [
filterProperties(),
decl('--tw-drop-shadow-alpha', alpha),
decl(
'--tw-drop-shadow-size',
segment(value, ',')
.map(
(v) =>
`drop-shadow(${replaceShadowColors(
v,
alpha,
(color) => `var(--tw-drop-shadow-color, ${color})`,
)})`,
)
.join(' '),
),
decl('--tw-drop-shadow', `drop-shadow(${theme.resolve(null, ['--drop-shadow'])})`),
decl('filter', cssFilterValue),
]
}

if (candidate.value.kind === 'arbitrary') {
let value: string | null = candidate.value.value
let type = candidate.value.dataType ?? inferDataType(value, ['color'])

switch (type) {
case 'color': {
value = asColor(value, candidate.modifier, theme)
if (value === null) return
return [
filterProperties(),
decl('--tw-drop-shadow-color', withAlpha(value, 'var(--tw-drop-shadow-alpha)')),
decl('--tw-drop-shadow', `var(--tw-drop-shadow-size)`),
]
}
default: {
if (candidate.modifier && !alpha) return

return [
filterProperties(),
decl('--tw-drop-shadow-alpha', alpha),
decl(
'--tw-drop-shadow-size',
segment(value, ',')
.map(
(v) =>
`drop-shadow(${replaceShadowColors(
v,
alpha,
(color) => `var(--tw-drop-shadow-color, ${color})`,
)})`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the API changed here because this is passing 3 values instead of 2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think it's because I pressed the update button (because of conflicts in the CHANGELOG.md file)

)
.join(' '),
),
decl('--tw-drop-shadow', `var(--tw-drop-shadow-size)`),
decl('filter', cssFilterValue),
]
}
}
}

// Shadow size
{
let value = theme.get([`--drop-shadow-${candidate.value.value}`])
if (value) {
if (candidate.modifier && !alpha) return

if (alpha) {
return [
filterProperties(),
decl('--tw-drop-shadow-alpha', alpha),
decl(
'--tw-drop-shadow-size',
segment(value, ',')
.map(
(v) =>
`drop-shadow(${replaceShadowColors(
v,
alpha,
(color) => `var(--tw-drop-shadow-color, ${color})`,
)})`,
)
.join(' '),
),
decl('--tw-drop-shadow', `var(--tw-drop-shadow-size)`),
decl('filter', cssFilterValue),
]
}

return [
filterProperties(),
decl('--tw-drop-shadow-alpha', alpha),
decl(
'--tw-drop-shadow-size',
segment(value, ',')
.map(
(v) =>
`drop-shadow(${replaceShadowColors(
v,
alpha,
(color) => `var(--tw-drop-shadow-color, ${color})`,
)})`,
)
.join(' '),
),
decl(
'--tw-drop-shadow',
`drop-shadow(${theme.resolve(candidate.value.value, ['--drop-shadow'])})`,
),
decl('filter', cssFilterValue),
]
}
}

// Shadow color
{
let value = resolveThemeColor(candidate, theme, ['--drop-shadow-color', '--color'])
if (value) {
return [
filterProperties(),
decl('--tw-drop-shadow-color', withAlpha(value, 'var(--tw-drop-shadow-alpha)')),
decl('--tw-drop-shadow', `var(--tw-drop-shadow-size)`),
]
}
}
})

suggest('drop-shadow', () => [
{
values: ['current', 'inherit', 'transparent'],
valueThemeKeys: ['--drop-shadow-color', '--color'],
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
},
{
valueThemeKeys: ['--drop-shadow'],
},
])

functionalUtility('backdrop-opacity', {
themeKeys: ['--backdrop-opacity', '--opacity'],
handleBareValue: ({ value }) => {
Expand Down
Loading
Loading