Skip to content

[v4] Border with arbitrary color using var #14181

Closed

Description

@sntran

What version of Tailwind CSS are you using?

v4.0.0-alpha.18

What build tool (or framework if it abstracts the build tool) are you using?

@tailwindcss/cli

What version of Node.js are you using?

v20.12.2

What browser are you using?

Chrome version 127.0.6533.89 (Official Build) (arm64)

What operating system are you using?

macOS 14.5

Reproduction URL

https://play.tailwindcss.com/fCI06uutZE

Describe your issue

When setting a one-off border width with custom properties, Tailwind sees that as arbitrary value for color, not width.

Expected:

border-b-[var(--spacing-4)]

outputs to

.border-b-\[var\(--spacing-4\)\] {
    border-bottom-width: var(--spacing-4);
}

Actual:

.border-b-\[var\(--spacing-4\)\] {
    border-bottom-color: var(--spacing-4);
}

Activity

  1. wongjn commented on Aug 13, 2024

    @wongjn
    Collaborator

    As per the documentation for v3 (but still relevant for v4):

    Many utilities in Tailwind share a common namespace but map to different CSS properties. For example text-lg and text-black both share the text- namespace, but one is for font-size and the other is for color.

    […]

    In these situations, you can “hint” the underlying type to Tailwind by adding a CSS data type before the value:

    So for your example, we can add length type hint like border-b-[length:var(--spacing-4)], see https://play.tailwindcss.com/sdp5nlRpvw.

  2. sntran commented on Aug 13, 2024

    @sntran
    ContributorAuthor

    As per the documentation for v3 (but still relevant for v4):

    Many utilities in Tailwind share a common namespace but map to different CSS properties. For example text-lg and text-black both share the text- namespace, but one is for font-size and the other is for color.
    […]
    In these situations, you can “hint” the underlying type to Tailwind by adding a CSS data type before the value:

    So for your example, we can add length type hint like border-b-[length:var(--spacing-4)], see https://play.tailwindcss.com/sdp5nlRpvw.

    Ah yes! I remember seeing that documentation, but could not find it in time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions