본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

유틸리티 클래스와 CSS 변수

원문 보기 위키 갱신

daisyUI가 제공하는 유용한 유틸리티 클래스와 CSS 변수들을 살펴볼게요. 색상 유틸리티, border radius, glass 효과, 테마/컴포넌트별 CSS 변수로 라이브러리를 더 효과적으로 쓸 수 있어요.

출처: 문서

본문

daisyUI는 라이브러리를 더 효과적으로 쓰게 해 주는 유용한 유틸리티 클래스와 CSS 변수 몇 가지를 제공해요.

색상 유틸리티 클래스

모든 daisyUI 색상은 유틸리티 클래스로 쓸 수 있어요. Tailwind CSS의 다른 색과 똑같이요. 예를 들어 primary 색을 Tailwind CSS 색 유틸리티들과 함께 쓸 수 있어요. 색상 이름에 대한 자세한 내용은 관련 문서를 참고하세요.

클래스 이름 설명
bg-primary 배경색을 primary 색으로 설정
to-primary 그라데이션의 끝 색을 primary 색으로 설정
via-primary 그라데이션의 중간 색을 primary 색으로 설정
from-primary 그라데이션의 시작 색을 primary 색으로 설정
text-primary 텍스트 색을 primary 색으로 설정
ring-primary ring 색을 primary 색으로 설정
fill-primary SVG 요소의 fill 색을 primary 색으로 설정
caret-primary caret 색을 primary 색으로 설정
stroke-primary SVG 요소의 stroke 색을 primary 색으로 설정
border-primary 테두리 색을 primary 색으로 설정
divide-primary 나누는 테두리 색을 primary 색으로 설정
accent-primary accent 색을 primary 색으로 설정
shadow-primary 그림자 색을 primary 색으로 설정
outline-primary outline 색을 primary 색으로 설정
decoration-primary 텍스트 데코레이션 색을 primary 색으로 설정
placeholder-primary 플레이스홀더 텍스트 색을 primary 색으로 설정
ring-offset-primary ring offset 색을 primary 색으로 설정

bg-primary로 배경색을, text-primary-content로 텍스트 색을 primary 색으로 설정할 수 있어요.

<div class="bg-primary text-primary-content">Primary color</div>

색의 불투명도도 조절할 수 있어요.

<div class="bg-primary text-primary-content/60">Primary-content color with 60% opacity</div>

Border radius

Tailwind CSS는 rounded-sm, rounded-lg, rounded-xl 같은 고정 border radius 값을 제공해요. daisyUI는 컴포넌트용으로 토큰화되어 테마에 따라 커스터마이징할 수 있는 border radius 값 몇 개를 더 제공해요. 테마를 바꿔 보면 border radius가 달라지는 걸 볼 수 있어요.

클래스 이름 CSS 변수 설명
rounded-box var(--radius-box) card, modal, alert 같은 큰 컴포넌트용
rounded-field var(--radius-field) button, input, select, tab 같은 중간 크기 컴포넌트용
rounded-selector var(--radius-selector) checkbox, toggle, badge 같은 작은 컴포넌트용

Glass

glass는 요소에 유리 효과를 만들어 줘요.

<div class="glass">Glass</div>

테마 CSS 변수

이 CSS 변수들은 테마마다 커스터마이징할 수 있어요. 색상 이름에 대한 자세한 내용은 관련 문서를 참고하세요.

CSS 변수 설명
--color-primary primary 브랜드 색
--color-primary-content primary 색 위에 쓸 전경 콘텐츠 색
--color-secondary secondary 브랜드 색
--color-secondary-content secondary 색 위에 쓸 전경 콘텐츠 색
--color-accent accent 브랜드 색
--color-accent-content accent 색 위에 쓸 전경 콘텐츠 색
--color-neutral 중립 어두운 색
--color-neutral-content neutral 색 위에 쓸 전경 콘텐츠 색
--color-base-100 페이지의 베이스 색, 빈 배경용
--color-base-200 더 어두운 베이스 색
--color-base-300 더더욱 어두운 베이스 색
--color-base-content base 색 위에 쓸 전경 콘텐츠 색
--color-info Info 색
--color-info-content info 색 위에 쓸 전경 콘텐츠 색
--color-success Success 색
--color-success-content success 색 위에 쓸 전경 콘텐츠 색
--color-warning Warning 색
--color-warning-content warning 색 위에 쓸 전경 콘텐츠 색
--color-error Error 색
--color-error-content error 색 위에 쓸 전경 콘텐츠 색
--radius-selector checkbox, toggle, badge 같은 selector의 border radius
--radius-field input, select, tab 같은 field의 border radius
--radius-box card, modal, alert 같은 box의 border radius
--size-selector checkbox, toggle, badge 같은 selector의 기본 스케일 크기
--size-field input, select, tab 같은 field의 기본 스케일 크기
--border 모든 컴포넌트의 테두리 너비
--depth (이진) 관련 컴포넌트에 depth 효과 추가
--noise (이진) 관련 컴포넌트에 배경 noise 효과 추가

컴포넌트별 CSS 변수

고급 사용을 위한 내용이에요. 이 CSS 변수들은 특정 컴포넌트에서 내부적으로 사용돼요. 보통은 커스터마이징할 필요가 없지만, 원한다면 할 수 있어요. daisyUI에 prefix를 쓰면 이 CSS 변수에도 그 prefix가 붙어요. 예를 들어 prefix가 daisy-라면, --alert-color CSS 변수는 --daisy-alert-color가 돼요.

이 변수들은 내부용이에요. 시맨틱 버저닝 대상이 아니며, 일부는 향후 마이너 버전에서 수정되거나 제거될 수 있어요. 그 경우 커스텀 스타일이 효력을 잃을 수 있으니, 이런 변수를 수정하고 UI가 커스터마이징된 값에 정말 의존한다면 최신 버전이 아니라 고정 버전의 daisyUI를 쓰는 게 안전해요.

컴포넌트 CSS 변수 설명
Alert --alert-color alert 색
Aura --aura-angle aura 그라데이션 각도
--aura-padding aura 효과의 padding
--aura-radius aura 효과의 border radius
Badge --badge-color badge 색
--size badge 크기
Button --btn-bg 버튼 배경색
--btn-border 버튼 테두리 색
--btn-border-style 버튼 테두리 스타일
--btn-color 버튼 배경색
--btn-fg 버튼 전경색
--btn-inset 버튼 inset 그림자
--btn-rest-fg 버튼의 기본/rest 상태 전경색
--btn-shadow 버튼 그림자
--btn-soft-bg 소프트 버튼의 배경 mix 베이스
--btn-p 버튼 padding
--size 버튼 크기
Card --card-p 카드 body의 padding
--card-fs 카드 body의 글자 크기
--cardtitle-fs 카드 제목의 글자 크기
Checkbox --size checkbox 크기
Countdown --value countdown 값
--digits countdown의 최소 자릿수
Collapse --overflow-delay collapse 콘텐츠의 overflow 전환 지연
Divider --divider-m divider의 margin
Dropdown --anchor-v 앵커의 세로 위치
--anchor-h 앵커의 가로 위치
Fab --degree 플로팅 액션 버튼 항목의 각도
--position 플로팅 액션 버튼 항목의 거리
File input --input-color 파일 입력 색
--size 파일 입력 크기
Hover 3D --ease easing 애니메이션
--shadow 밑의 그림자 효과
--shine 오버레이 광택 효과
--transform transform 각도
Hover Gallery --items 항목 수
Indicator --indicator-t 인디케이터 위쪽 위치
--indicator-b 인디케이터 아래쪽 위치
--indicator-s 인디케이터 시작 위치
--indicator-e 인디케이터 끝 위치
--indicator-y 인디케이터 세로 위치
--indicator-x 인디케이터 가로 위치
Input --input-color input 색
--size input 크기
--font-size input 글자 크기
--font-size-min input 최소 글자 크기
--in-size-mul input 크기 배수
--spin-my 숫자 input 스핀 버튼의 세로 margin
--top-mul 플로팅 라벨 위쪽 위치 배수
Kbd --size kbd 크기
List --list-grid-cols list의 grid 열
Menu --menu-active-fg 활성 menu 항목 전경색
--menu-active-bg 활성 menu 항목 배경색
Megamenu --fontsize megamenu 항목 글자 크기
--mm-anchor megamenu 항목의 활성 앵커
--mm-backdrop megamenu의 backdrop 색
--mm-display megamenu 콘텐츠의 display 값
--mm-mt megamenu의 margin top
--mm-p megamenu 항목의 padding
--size megamenu 항목 크기
Modal --modal-tl modal 왼쪽 위 border radius
--modal-tr modal 오른쪽 위 border radius
--modal-bl modal 왼쪽 아래 border radius
--modal-br modal 오른쪽 아래 border radius
OTP --input-color OTP 입력 색
--otp-ch OTP 입력 문자 너비
--otp-gap OTP 입력 상자 간격
--otp-size OTP 입력 상자 크기
--otp-w OTP 입력 상자 너비
--stride OTP 입력 상자의 spacing stride
Radial progress --value radial progress 값
--size radial progress 크기
--thickness radial progress 두께
--radialprogress radial progress 위치 계산용
Radio --size radio 크기
Range --range-bg range 슬라이더 thumb 배경색
--range-thumb range 슬라이더 thumb 색
--range-thumb-size range 슬라이더 thumb 크기
--range-progress range 슬라이더 진행 색
--range-fill (이진) range 슬라이더 진행 채움 여부
--range-fill-spread range 슬라이더 채움의 spread
--range-fill-x range 슬라이더 채움의 가로 offset
--range-fill-y range 슬라이더 채움의 세로 offset
--range-p range 슬라이더 thumb padding
--size range 슬라이더 크기
Rating --size rating 요소 크기
Select --input-color input 색
--size select 크기
--font-size select 글자 크기
--font-size-min select 최소 글자 크기
--option-px select 옵션의 가로 padding
--sl-size-mul select 크기 배수
--top-mul 플로팅 라벨 위쪽 위치 배수
Tab --tabs-height tabs 높이
--tabs-direction tabs 방향
--tab-p tab padding
--tab-bg tab 배경색
--tab-border-color tab 테두리 색
--tab-radius-ss tab의 시작-시작 border radius
--tab-radius-se tab의 시작-끝 border radius
--tab-radius-es tab의 끝-시작 border radius
--tab-radius-ee tab의 끝-끝 border radius
--tab-order tab 순서
--tab-radius-min lift tab의 최소 border radius
--tab-paddings lift tab의 모든 padding 값
--tab-border-colors lift tab의 모든 테두리 색 값
--tab-corner-width lift tab의 코너 너비
--tab-corner-height lift tab의 코너 높이
--tab-corner-position lift tab의 코너 위치
--tab-inset lift tab의 inset 위치
--radius-start lift tab 코너의 border radius
--radius-end lift tab 코너의 border radius
--tabcontent-margin tab 콘텐츠의 margin
--tabcontent-radius-ss tab 콘텐츠의 시작-시작 border radius
--tabcontent-radius-se tab 콘텐츠의 시작-끝 border radius
--tabcontent-radius-es tab 콘텐츠의 끝-시작 border radius
--tabcontent-radius-ee tab 콘텐츠의 끝-끝 border radius
--tabcontent-order tab 콘텐츠 순서
Text Rotate --items 항목 수
--duration 루프 전체 시간(밀리초)
--first-item-position 첫 항목의 동적 위치
Textarea --input-color input 색
--size textarea 크기
--font-size textarea 글자 크기
--font-size-min textarea 최소 글자 크기
--top-mul 플로팅 라벨 위쪽 위치 배수
Timeline --timeline-row-start timeline 행 시작 위치
--timeline-row-end timeline 행 끝 위치
--timeline-col-start timeline 열 시작 위치
--timeline-col-end timeline 열 끝 위치
Toast --toast-x toast 가로 위치
--toast-y toast 세로 위치
Toggle --toggle-p toggle padding
--size toggle 크기
Tooltip --tt-bg tooltip 배경색
--tt-off tooltip offset
--tt-inset tooltip의 inset 위치
--tt-tail tooltip 꼬리 위치
--tt-tail-inset tooltip 꼬리의 inset 위치
--tt-tail-off 시작/끝에서 tooltip 꼬리의 offset
--tt-trans tooltip의 transform offset
Glass --glass-blur glass 효과의 blur
--glass-opacity glass 효과의 opacity
--glass-reflect-degree glass 반사의 각도
--glass-reflect-opacity glass 반사의 opacity
--glass-border-opacity glass 테두리의 opacity
--glass-text-shadow-opacity glass 텍스트 그림자의 opacity
Join --join-h 가로 join 방향
--join-v 세로 join 방향

컴포넌트별 CSS 변수 커스터마이징 예제

  • 유틸리티 클래스로 --alert-color 커스터마이징 (html):
<div class="alert [--alert-color:blue]">
  <span>12 unread messages. Tap to see.</span>
</div>
  • CSS에서 --alert-color 커스터마이징 (css):
@import "tailwindcss";
@plugin "daisyui";

.alert {
  --alert-color: blue;
}

더 알아보기 (Learn more)

컴포넌트별 CSS 변수는 고급 사용을 위한 것이고, 대부분은 손댈 필요가 없어요. 다만 --radius-*, --size-*, --border 같은 테마 변수는 테마 전체의 일관된 분위기를 잡을 때 유용하게 쓸 수 있어요.