# Source: https://github.com/tailwindlabs/tailwindcss.com/blob/main/src/docs/min-width.mdx

import { ApiTable } from "@/components/api-table.tsx";
import { Stripes } from "@/components/stripes.tsx";
import { CustomizingYourSpacingScale, ResponsiveDesign, UsingACustomValue } from "@/components/content.tsx";
import { Example } from "@/components/example.tsx";
import { Figure } from "@/components/figure.tsx";

export const title = "min-width";
export const description = "Utilities for setting the minimum width of an element.";

<ApiTable
  rows={[
    ["min-w-<number>", "min-width: calc(var(--spacing) * <number>);"],
    ["min-w-<fraction>", "min-width: calc(<fraction> * 100%);"],
    ["min-w-3xs", "min-width: var(--container-3xs); /* 16rem (256px) */"],
    ["min-w-2xs", "min-width: var(--container-2xs); /* 18rem (288px) */"],
    ["min-w-xs", "min-width: var(--container-xs); /* 20rem (320px) */"],
    ["min-w-sm", "min-width: var(--container-sm); /* 24rem (384px) */"],
    ["min-w-md", "min-width: var(--container-md); /* 28rem (448px) */"],
    ["min-w-lg", "min-width: var(--container-lg); /* 32rem (512px) */"],
    ["min-w-xl", "min-width: var(--container-xl); /* 36rem (576px) */"],
    ["min-w-2xl", "min-width: var(--container-2xl); /* 42rem (672px) */"],
    ["min-w-3xl", "min-width: var(--container-3xl); /* 48rem (768px) */"],
    ["min-w-4xl", "min-width: var(--container-4xl); /* 56rem (896px) */"],
    ["min-w-5xl", "min-width: var(--container-5xl); /* 64rem (1024px) */"],
    ["min-w-6xl", "min-width: var(--container-6xl); /* 72rem (1152px) */"],
    ["min-w-7xl", "min-width: var(--container-7xl); /* 80rem (1280px) */"],
    ["min-w-auto", "min-width: auto;"],
    ["min-w-px", "min-width: 1px;"],
    ["min-w-full", "min-width: 100%;"],
    ["min-w-screen", "min-width: 100vw;"],
    ["min-w-dvw", "min-width: 100dvw;"],
    ["min-w-dvh", "min-width: 100dvh;"],
    ["min-w-lvw", "min-width: 100lvw;"],
    ["min-w-lvh", "min-width: 100lvh;"],
    ["min-w-svw", "min-width: 100svw;"],
    ["min-w-svh", "min-width: 100svh;"],
    ["min-w-min", "min-width: min-content;"],
    ["min-w-max", "min-width: max-content;"],
    ["min-w-fit", "min-width: fit-content;"],
    ["min-w-(<custom-property>)", "min-width: var(<custom-property>);"],
    ["min-w-[<value>]", "min-width: <value>;"],
  ]}
/>

## Examples

### Basic example

Use `min-w-<number>` utilities like `min-w-24` and `min-w-64` to set an element to a fixed minimum width based on the spacing scale:

<Figure>

<Example>
  {
    <div className="relative mx-auto grid w-60 justify-items-start gap-y-4 text-center font-mono text-xs font-bold text-white">
      <Stripes border className="absolute -inset-y-4 w-20 rounded-lg" />
      <div className="relative min-w-80 rounded-lg bg-sky-500 px-4 py-2">min-w-80</div>
      <div className="relative min-w-64 rounded-lg bg-sky-500 px-4 py-2">min-w-64</div>
      <div className="relative min-w-48 rounded-lg bg-sky-500 px-4 py-2">min-w-48</div>
      <div className="relative min-w-40 rounded-lg bg-sky-500 px-4 py-2">min-w-40</div>
      <div className="relative min-w-32 rounded-lg bg-sky-500 px-4 py-2">min-w-32</div>
      <div className="relative min-w-24 rounded-lg bg-sky-500 px-4 py-2">min-w-24</div>
    </div>
  }
</Example>

```html
<!-- [!code classes:min-w-96,min-w-80,min-w-64,min-w-48,min-w-40,min-w-32,min-w-24,min-w-full] -->
<div class="w-20 ...">
  <div class="min-w-80 ...">min-w-80</div>
  <div class="min-w-64 ...">min-w-64</div>
  <div class="min-w-48 ...">min-w-48</div>
  <div class="min-w-40 ...">min-w-40</div>
  <div class="min-w-32 ...">min-w-32</div>
  <div class="min-w-24 ...">min-w-24</div>
</div>
```

</Figure>

### Using a percentage

Use `min-w-full` or `min-w-<fraction>` utilities like `min-w-1/2` and `min-w-2/5` to give an element a percentage-based minimum width:

<Figure>

<Example>
  {
    <div className="relative mx-auto my-6 flex w-full justify-items-start gap-3 text-center font-mono text-xs font-bold text-white">
      <Stripes border className="absolute inset-x-0 -inset-y-3 rounded-lg" />
      <div className="relative min-w-2/3 rounded-lg bg-indigo-500 px-4 py-2">min-w-3/4</div>
      <div className="relative w-full rounded-lg bg-indigo-300 px-4 py-2 dark:bg-indigo-800 dark:text-indigo-400">
        w-full
      </div>
    </div>
  }
</Example>

```html
<!-- [!code classes:min-w-3/4] -->
<div class="flex ...">
  <div class="min-w-3/4 ...">min-w-3/4</div>
  <div class="w-full ...">w-full</div>
</div>
```

</Figure>

### Using the container scale

Use utilities like `min-w-sm` and `min-w-xl` to set an element to a fixed minimum width based on the container scale:

<Figure>

<Example>
  {
    <div className="relative grid justify-items-start gap-y-4 text-center font-mono text-xs font-bold text-white">
      <Stripes border className="absolute -inset-y-4 w-40 rounded-lg" />
      <div className="relative hidden min-w-lg rounded-lg bg-blue-500 px-4 py-2 sm:block">min-w-lg</div>
      <div className="relative hidden min-w-md rounded-lg bg-blue-500 px-4 py-2 sm:block">min-w-md</div>
      <div className="relative hidden min-w-sm rounded-lg bg-blue-500 px-4 py-2 sm:block">min-w-sm</div>
      <div className="relative min-w-xs rounded-lg bg-blue-500 px-4 py-2">min-w-xs</div>
      <div className="relative min-w-2xs rounded-lg bg-blue-500 px-4 py-2">min-w-2xs</div>
      <div className="relative min-w-3xs rounded-lg bg-blue-500 px-4 py-2">min-w-3xs</div>
    </div>
  }
</Example>

```html
<!-- [!code classes:min-w-lg,min-w-md,min-w-sm,min-w-xs,min-w-2xs,min-w-3xs] -->
<div class="w-40 ...">
  <div class="min-w-lg ...">min-w-lg</div>
  <div class="min-w-md ...">min-w-md</div>
  <div class="min-w-sm ...">min-w-sm</div>
  <div class="min-w-xs ...">min-w-xs</div>
  <div class="min-w-2xs ...">min-w-2xs</div>
  <div class="min-w-3xs ...">min-w-3xs</div>
</div>
```

</Figure>

### Using a custom value

<UsingACustomValue utility="min-w" value="220px" name="minimum width" variable="min-width" />

### Responsive design

<ResponsiveDesign property="min-width" defaultClass="w-24 min-w-full" featuredClass="min-w-0" />

## Customizing your theme

<CustomizingYourSpacingScale utility="min-w" />