search

Home  >  Q&A  >  body text

Vue + Tailwind: Themeable profile page

<p>I want to create an application (similar to a social network) that lets users sign up and enter a bunch of profile information. Thereafter, the user can select a theme (from a set of predefined themes) to display this information to other users viewing the profile. </p> <p>This is very similar to Shopify’s storefront theme. </p> <p>How should I try to design a solution for this? </p> <p>Sorry in advance for a very advanced vague question. </p> <p>I know how to set the theme and/or colors etc while writing code (or maybe during the build step), but I'm even trying to reason about how to do this inside the product. </p>
P粉155710425P粉155710425575 days ago717

reply all(1)I'll reply

  • P粉762447363

    P粉7624473632023-09-04 14:04:32

    You can use tw-colors to create a predefined theme

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    const { createThemes } = require('tw-colors');

     

    module.exports = {

       content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],

       plugins: [

          createThemes({

             banana: {

                'primary': 'steelblue',

                'secondary': 'darkblue',

                'brand': '#F3F3F3',

             },

             halloween: {

                'primary': 'turquoise',

                'secondary': 'tomato',

                'brand': '#4A4A4A',

             },

             darkula: {

                'primary': '#2A9D8F',

                'secondary': '#E9C46A',

                'brand': '#264653',

             },

          })

       ],

    };

    Then apply the theme to the card container

    1

    2

    3

    4

    5

    6

    7

    8

    9

    <div class='theme-darkcula'>

        <h2 class='text-primary'>Username</h2>

        <p class='text-secondary'>...</p>

    </div>

     

    <div class='theme-halloween'>

        <h2 class='text-primary'>Username</h2>

        <p class='text-secondary'>...</p>

    </div>

    If subject class names come from API responses, you should safelist them, otherwise tailwind will not generate them, see tailwind documentation for more details

    reply
    0
  • Cancelreply