Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Fixed broken color styles ([#405](https://github.com/tailwindlabs/tailwindcss-typography/pull/405))

## [0.5.18] - 2025-09-19

Expand Down
10 changes: 6 additions & 4 deletions src/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ const opacity = (color, opacity) => {
// values.
let hex = color.replace('#', '')
hex = hex.length === 3 ? hex.replace(/./g, '$&$&') : hex
Copy link
Member

Choose a reason for hiding this comment

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

Hah unrelated to this, but TIL about $&

const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)

let r = parseInt(hex.substring(0, 2), 16)
let g = parseInt(hex.substring(2, 4), 16)
let b = parseInt(hex.substring(4, 6), 16)

if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
return `color-mix(in oklab, ${color} ${opacity}, transparent)`
}
return `rgb(${r}, ${g}, ${b} / ${opacity})`

return `rgb(${r} ${g} ${b} / ${opacity})`
}

let defaultModifiers = {
Expand Down