search

Home  >  Q&A  >  body text

How to change the font family in the Tailwind component

I have a select component and I want to set a custom font, just like another input box

<select data-te-select-init data-te-select-font="14">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
  </select>3
P粉037215587P粉037215587486 days ago559

reply all(1)I'll reply

  • P粉347804896

    P粉3478048962023-09-15 00:51:58

    Consider using the option classes to apply custom classes to select elements. This allows the font-family utility class to be used to apply the desired font-family.

    For example, we can apply mono font-family to formOutline## by using the data-te-class-form-outline attribute # element, as shown below:

    tailwind.config = {
      darkMode: "class"
      corePlugins: {
        preflight: false,
      },
    };
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tw-elements/dist/css/tw-elements.min.css" />
    <script src="https://cdn.tailwindcss.com/3.3.3"></script>
    
    <select data-te-select-init data-te-select-font="14" data-te-class-form-outline="relative font-mono">
      <option value="0">0</option>
      <option value="1">1</option>
      <option value="2">2</option>
    </select>3
    
    <script src="https://cdn.jsdelivr.net/npm/tw-elements/dist/js/tw-elements.umd.min.js"></script>

    reply
    0
  • Cancelreply