Skip to content

Make class names more consistent/closer to CSS #575

@missmatsuko

Description

@missmatsuko

Along the lines of #19, I am finding a lot of the class names unintuitive and inconsistent.

I really think the class names should favour clarity and ease-of-use over brevity, and lean on what developers should know about CSS.

Developers should know the property and value they want to apply to an element and it should be less effort for them to write class names of the property and value they want than to think about how its associated utility class name is formatted.

My suggestion is to use the format .[property name]-[property value] for all CSS utilities that only modify the value of one property. e.g. .margin-0 instead of .m-0, .align-items-stretch instead of .items-stretch, .text-transform-none instead of .normal-case, .max-width instead of .container.

Examples of some inconsistencies

  • Some class names come from the property:
    • .pointer-events for pointer-events
    • .appearance for appearance
    • .resize for resize
  • Some class names come from the attribute's value:
    • .block for display: block;
    • .flex for display: flex;
    • .visible for visibility: visible
  • Some class names come from some combination of property and value, with something omitted:
    • .items-stretch for align-items: stretch
    • .flex-row for flex-direction: row
    • .table-auto for table-layout: auto
  • Some class names use terminology that isn't used in CSS:
    • .invisible for visibility: hidden
    • .tracking for letter-spacing
    • .normal-case for text-transform: none;
  • Some class names mix up terminology that is used in CSS:
    • .justify for justify-content, not text-align: justify
    • .text for font-size, not text-transform
    • .align for vertical-align , not align-items
  • Some class names use abbreviations:
    • .m for margin
    • .z for z-index
    • .p for padding

Additionally, I think there are some class names that could reasonably be used for components or layout utilities. This would be mitigated if utility classes were named after their respective CSS property and value.

  • .block could be a boxy layout element
  • .content could be a content-containing element
  • .select could be a select input
  • .scrolling could be a state class to use with JS

This would also better distinguish single-property utility classes from complex utility classes such as:

  • .clearfix
  • .list-reset
  • .truncate

Andd I'm not sure if it's already a functionality that exists, but maybe developers can shorten the base class names according to their own preferences. I think it would be best to mimick CSS by default, though.

Related Issues:

#413 .font-normal .font-regular .roman .font-not-italic
#577 .hidden .visible
#102 and #523 Customizable class names

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