@tsed/tailwind-formio
v3.0.2
Published
Tailwind templates for form.io forms.
Readme
This repository will change the rendering of forms in formio.js so that it uses html and classes compatible with the Semantic UI framework.
Install
npm install @tsed/tailwind-formio --save
npm install tailwindcss postcss autoprefixer postcss-normalize --save-devTailwind configuration
Configure postcss
Edit postcss.config.js and add the postcss plugins list:
export default {
plugins: {
"postcss-normalize": {},
"tailwindcss/nesting": {},
tailwindcss: {},
autoprefixer: {}
}
};Configure tailwind
Edit your tailwind.config.js and copy the following content:
import { tailwindPreset } from "@tsed/tailwind-formio/tailwind.preset";
const primary = "hsla(208, 100%, 43%, 1)";
const secondary = "hsla(190, 81%, 42%, 1)";
module.exports = {
content: [
"./node_modules/**/*.{js,jsx,ts,tsx,ejs}"
// add your paths
],
presets: [tailwindPreset],
darkMode: "class",
theme: {
extend: {
colors: {
primary: {
DEFAULT: primary,
50: "hsla(208, 100%, 91%, 1)",
100: "hsla(208, 100%, 83%, 1)",
200: "hsla(208, 100%, 75%, 1)",
300: "hsla(208, 100%, 67%, 1)",
400: "hsla(208, 100%, 59%, 1)",
500: "hsla(208, 100%, 51%, 1)",
600: primary,
700: "hsla(208, 100%, 35%, 1)",
800: "hsla(208, 100%, 27%, 1)",
900: "hsla(208, 100%, 19%, 1)"
},
secondary: {
DEFAULT: secondary,
50: "hsla(190, 81%, 90%, 1)",
100: "hsla(190, 81%, 82%, 1)",
200: "hsla(190, 81%, 74%, 1)",
300: "hsla(190, 81%, 66%, 1)",
400: "hsla(190, 81%, 58%, 1)",
500: "hsla(190, 81%, 50%, 1)",
600: secondary,
700: "hsla(190, 81%, 34%, 1)",
800: "hsla(190, 81%, 28%, 1)",
900: "hsla(190, 81%, 20%, 1)"
},
"gray-darker": "#504747"
}
}
}
};Then create a tailwind.css in styles directory and add the following lines:
@tailwind base;
@tailwind components;
@tailwind utilities;Import the tailwind.css in the index.css created by create-react-app:
@import "@formio/js/dist/formio.full.css";
@import "./tailwind.css";
@import "@tsed/tailwind-formio/styles/index.css";Optionally, you can import fonts and icons:
@import "@formio/js/dist/formio.full.css";
@import "./tailwind.css";
+@import "@tsed/tailwind-formio/fonts/source-sans-pro/index.css";
+@import "@tsed/tailwind-formio/fonts/inconsolata/index.css";
+@import "lucide-static/font/lucide.css"; // if you want to use lucide icons (you have to install it)
+@import "./fonts/bxicons/index.css"; // if you want to use bxicons (you have to install it)
@import "@tsed/tailwind-formio/styles/index.css";Now, we can configure formio to use the tailwind template in our React application.
So edit the index.js (or index.ts):
import React from 'react';
import ReactDOM from 'react-dom';
+import { Formio, Templates } from "@tsed/react-formio";
+import tailwind from "@tsed/tailwind-formio";
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
+Formio.use(tailwind);
+Templates.framework = "tailwind";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();Finally, start the application!
Contributors
Please read contributing guidelines here.
Backers
Thank you to all our backers! 🙏 [Become a backer]
Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
License
The MIT License (MIT)
Copyright (c) 2016 - 2021 Romain Lenzotti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
