theme-ui icon indicating copy to clipboard operation
theme-ui copied to clipboard

Inability to use `border` CSS and reference base-theme colors in variants, must use long-hand border properties.

Open anmpog opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. When defining variants or styles.root values, I've found that I'm unable to reference the theme.colors object when defining borders using the CSS border shorthand (ex border: 2px solid primary where primary is a color defined on the theme.colors object). However, I CAN reference the colors defined on the theme.colors object when I use the longhand border-color CSS property.

Very specifically, on theme.styles.root I'm setting some default styling on the <section> element, and was attempting to define a border style using border: '2px solid primary to no effect – however, using:

section: {
  borderWidth: '2px',
  borderStyle: 'solid',
  borderColor: 'primary'

... works as intended ('primary' correctly references a color on my theme.colors object).

Describe the solution you'd like It would be nice to be able to reference theme values using the CSS border shorthand.

anmpog avatar Feb 02 '22 07:02 anmpog

Totally! There's two approaches I see here:

  1. Make it less annoying to write out the multi-part syntax, via something like nested objects, prototyped here but never finished: https://github.com/system-ui/theme-ui/compare/css-shorthands?expand=1
  2. Support (theme) => value function in theme specification, #2066

lachlanjc avatar Feb 05 '22 04:02 lachlanjc

Going to close for now in favor of the second solution I mentioned, which is a still-open issue!

lachlanjc avatar Nov 15 '22 03:11 lachlanjc