Skip to content

Utility 클래스

네이밍 원칙

CSS를 아는 사람이면 newtil-css를 바로 쓸 수 있어야 한다.

Tailwind는 p-4, bg-blue-500 같은 자체 명칭을 사용합니다. newtil-css는 실제 CSS 속성명을 그대로 쓰거나 누구나 유추할 수 있는 축약을 제공합니다.

.padding:4          → padding: var(--space-4)
.p:4                → 같은 것 (축약)
.background-color:primary → background-color: var(--color-primary)
.bg:primary         → 같은 것 (축약)

유틸 활용하기

유틸만 사용하기

디자인 시스템의 토큰만 활용해서 컴포넌트를 직접 만들 수 있습니다. 라이브러리에 없는 모양이나 빠르게 프로토타이핑할 때 유용합니다.

버튼 만들기

카드 만들기

컴포넌트에 유틸로 커스텀하기

@newtil/components 같은 컴포넌트 라이브러리 위에 유틸리티를 조합하면, 컴포넌트의 기본 모양은 유지하면서 특정 상황에 맞는 조정을 빠르게 할 수 있습니다.

버튼에 간격/정렬 추가

카드를 그리드 레이아웃에 배치

컴포넌트 변수를 유틸로 재정의

컴포넌트 변수는 일반 CSS 변수이므로 유틸이나 인라인 스타일로 오버라이드 가능합니다.

함께 쓰기 좋은 이유

@newtil/components는 모든 속성을 컴포넌트 변수로 노출하고, @newtil/css는 그 변수를 유틸리티 클래스로 조작할 수 있는 수단을 제공합니다. 두 라이브러리는 같은 design-tokens를 공유해서 색/간격/그림자가 자연스럽게 맞습니다.

전체 카테고리 목록

Core

카테고리속성축약
Displaydisplay:flexd:flex
Positionposition:absolute, top:4, z-index:modalpos:absolute, z:modal
Spacingmargin:4, margin-top:3, margin-x:auto, padding:5, gap:3m:4, mt:3, mx:auto, p:5, g:3
Sizingwidth:full, height:11, min-width:14, max-height:screen-hw:full, h:11, min-w:14, max-h:screen-h
Colorcolor:primary, background-color:surface, border-color:borderc:primary, bg:surface, bdc:border
Typographyfont-size:md, font-weight:bold, line-height:normal, text-align:centerfs:md, fw:bold, lh:normal, ta:center
Borderborder-width:1, border-style:solid, border-radius:3bdw:1, bds:solid, bdr:3
Flexboxflex-direction:column, justify-content:center, align-items:centerfd:column, jc:center, ai:center
Gridgrid-template-columns:3, grid-column:span-2gtc:3, gcs:span-2
Effectsopacity:50, box-shadow:md, cursor:pointer, overflow:hiddenop:50, bsh:md, cur:pointer, of:hidden
Transitiontransition:default, transition-duration:fasttr:default, tdur:fast
Transformtranslate-x:4, rotate:45, scale:110trx:4, rot:45, scl:110
Outlineoutline-width:2, outline-style:solid, outline-color:focus-ringolw:2, ols:solid, olc:focus-ring
Backgroundbackground-size:cover, background-position:centerbgs:cover, bgp:center
Font Familyfont-family:sans, font-family:monoff:sans, ff:mono
Text Extrastext-shadow:md, text-wrap:balance, text-overflow:ellipsistsh:md, tw:balance, to:ellipsis

추가 카테고리

카테고리속성 예시축약
Filterblur:md, brightness:110, grayscale:100blr:md, brt:110, gray:100
Backdrop Filterbackdrop-blur:lgbdblr:lg
Aspect Ratioaspect-ratio:video, aspect-ratio:squarear:video, ar:square
Objectobject-fit:cover, object-position:centerofit:cover, opos:center
Animationanimation:spin, animation:pulseanim:spin, anim:pulse
Scrollscroll-snap-type:y, scroll-behavior:smoothsst:y, sb:smooth
Interactionuser-select:none, pointer-events:noneus:none, pe:none
Blendmix-blend-mode:multiply, isolation:isolatembm:multiply, iso:isolate
SVGfill:primary, stroke:border, stroke-width:1
Tablestable-layout:fixed, border-collapse:collapsetl:fixed
Listslist-style-type:disclst:disc
Columnscolumn-count:3cc:3
Legacyfloat:left, clear:bothfl:left, cl:both
Logicalmargin-inline:4, padding-block:3, inset-inline:0

합성 유틸 (Composite)

클래스효과
.truncate한 줄 말줄임표 (overflow:hidden + text-overflow:ellipsis + white-space:nowrap)
.line-clamp:33줄 말줄임표
.sr-only시각 숨김, 스크린리더 접근 가능
.not-sr-onlysr-only 해제
.centerflex 중앙정렬
.center-colflex column 중앙정렬
.fixed-centerabsolute 중앙 (translate -50%)
.stack:3flex column + gap:3
.hstack:3flex row + align-center + gap:3

값 체계

Spacing / Sizing (rem 기반, 4px 그리드)

인덱스값 (rem)약 px
000
10.125rem2px
20.25rem4px
30.5rem8px
40.75rem12px
51rem16px
61.25rem20px
71.5rem24px
82rem32px
92.5rem40px
103rem48px
114rem64px
125rem80px
136rem96px
148rem128px

분수 Size

width:1-2 (50%), width:1-3 (33.3%), width:2-3 (66.7%), width:1-4 (25%), width:3-4 (75%) 등.

색상

Design Tokens 가이드 참고