Bordes
Utilidades para controlar el ancho de los bordes de un elemento.
Clase | Estilos |
---|---|
border | border-width: 1px; |
border-<number> | border-width: <number>px; |
border-(length:<custom-property>) | border-width: var(<custom-property>); |
border-[<value>] | border-width: <value>; |
border-x | border-inline-width: 1px; |
border-x-<number> | border-inline-width: <number>px; |
border-x-(length:<custom-property>) | border-inline-width: var(<custom-property>); |
border-x-[<value>] | border-inline-width: <value>; |
border-y | border-block-width: 1px; |
border-y-<number> | border-block-width: <number>px; |
border-y-(length:<custom-property>) | border-block-width: var(<custom-property>); |
border-y-[<value>] | border-block-width: <value>; |
border-s | border-inline-start-width: 1px; |
border-s-<number> | border-inline-start-width: <number>px; |
border-s-(length:<custom-property>) | border-inline-start-width: var(<custom-property>); |
border-s-[<value>] | border-inline-start-width: <value>; |
border-e | border-inline-end-width: 1px; |
border-e-<number> | border-inline-end-width: <number>px; |
border-e-(length:<custom-property>) | border-inline-end-width: var(<custom-property>); |
border-e-[<value>] | border-inline-end-width: <value>; |
border-t | border-top-width: 1px; |
border-t-<number> | border-top-width: <number>px; |
border-t-(length:<custom-property>) | border-top-width: var(<custom-property>); |
border-t-[<value>] | border-top-width: <value>; |
border-r | border-right-width: 1px; |
border-r-<number> | border-right-width: <number>px; |
border-r-(length:<custom-property>) | border-right-width: var(<custom-property>); |
border-r-[<value>] | border-right-width: <value>; |
border-b | border-bottom-width: 1px; |
border-b-<number> | border-bottom-width: <number>px; |
border-b-(length:<custom-property>) | border-bottom-width: var(<custom-property>); |
border-b-[<value>] | border-bottom-width: <value>; |
border-l | border-left-width: 1px; |
border-l-<number> | border-left-width: <number>px; |
border-l-(length:<custom-property>) | border-left-width: var(<custom-property>); |
border-l-[<value>] | border-left-width: <value>; |
divide-x | & > :not(:last-child) {
border-inline-start-width: 0px;
border-inline-end-width: 1px;
} |
divide-x-<number> | & > :not(:last-child) {
border-inline-start-width: 0px;
border-inline-end-width: <number>px;
} |
divide-x-(length:<custom-property>) | & > :not(:last-child) {
border-inline-start-width: 0px;
border-inline-end-width: var(<custom-property>);
} |
divide-x-[<value>] | & > :not(:last-child) {
border-inline-start-width: 0px;
border-inline-end-width: <value>;
} |
divide-y | & > :not(:last-child) {
border-top-width: 0px;
border-bottom-width: 1px;
} |
divide-y-<number> | & > :not(:last-child) {
border-top-width: 0px;
border-bottom-width: <number>px;
} |
divide-y-(length:<custom-property>) | & > :not(:last-child) {
border-top-width: 0px;
border-bottom-width: var(<custom-property>);
} |
divide-y-[<value>] | & > :not(:last-child) {
border-top-width: 0px;
border-bottom-width: <value>;
} |
divide-x-reverse | --tw-divide-x-reverse: 1; |
divide-y-reverse | --tw-divide-y-reverse: 1; |
Usa utilidades border
o border-<number>
como border-2
y border-4
para establecer el ancho del borde para todos los lados de un elemento:
border
border-2
border-4
border-8
<div class="border border-indigo-600 ..."></div><div class="border-2 border-indigo-600 ..."></div><div class="border-4 border-indigo-600 ..."></div><div class="border-8 border-indigo-600 ..."></div>
Usa utilidades como border-r
y border-t-4
para establecer el ancho del borde para un lado de un elemento:
border-t-4
border-r-4
border-b-4
border-l-4
<div class="border-t-4 border-indigo-500 ..."></div><div class="border-r-4 border-indigo-500 ..."></div><div class="border-b-4 border-indigo-500 ..."></div><div class="border-l-4 border-indigo-500 ..."></div>
Usa utilidades como border-x
y border-y-4
para establecer el ancho del borde en dos lados de un elemento al mismo tiempo:
border-x-4
border-y-4
<div class="border-x-4 border-indigo-500 ..."></div><div class="border-y-4 border-indigo-500 ..."></div>
Usa utilidades como border-s
y border-e-4
para establecer las propiedades lógicas border-inline-start-width
y border-inline-end-width
, que se asignan al borde izquierdo o derecho según la dirección del texto:
De izquierda a derecha
De derecha a izquierda
<div dir="ltr"> <div class="border-s-4 ..."></div></div><div dir="rtl"> <div class="border-s-4 ..."></div></div>
Usa utilidades como divide-x
y divide-y-4
para agregar bordes entre elementos hijos:
<div class="grid grid-cols-3 divide-x-4"> <div>01</div> <div>02</div> <div>03</div></div>
Si tus elementos están en orden inverso (usando, por ejemplo, flex-row-reverse
o flex-col-reverse
), usa las utilidades divide-x-reverse
o divide-y-reverse
para asegurarte de que el borde se agregue al lado correcto de cada elemento:
<div class="flex flex-col-reverse divide-y-4 divide-y-reverse divide-gray-200"> <div>01</div> <div>02</div> <div>03</div></div>
Usa la sintaxis border-[<value>]
para establecer el border width basado en un valor completamente personalizado:
<div class="border-[2vw] ..."> <!-- ... --></div>
Para variables CSS, también puedes usar la sintaxis border-(length:<custom-property>)
:
<div class="border-(length:--my-border-width) ..."> <!-- ... --></div>
Esto es solo un atajo para border-[length:var(<custom-property>)]
que agrega la función var()
por ti automáticamente.
Prefija una utilidad border-width
con una variante de breakpoint como md:
para aplicar la utilidad solo en tamaños de pantalla medium y superiores:
<div class="border-2 md:border-t-4 ..."> <!-- ... --></div>
Aprende más sobre el uso de variantes en la documentación de variantes.