The issue is pretty much the same as the title. I am on Vuetify's 1.5.24 version and I am currently trying to create a button with an icon inside it as per mentioned in the vuetify documentation.
<v-btn icon color="dark"><v-icon>filter-variant</v-icon></v-btn>
But what I end up with is an invisible button that has nothing displayed inside it. I am using the same code provided in the documentation but nothing worked.
I have already tried redoing my installation of mdi. Currently, my local environment of the front end is running in intellij in case the issue can be linked to that.
Have you tried to add:
mdi
the following code should work if you are using vuetify, also you can look at their documentation here
<v-btn icon color="dark" >
<v-icon>mdi-filter-variant</v-icon>
</v-btn>
Well, the step-to-step procedure is already mentioned in Vuetify 1.5.x documentation, however, here are some quick steps you can follow to set up the icons-
Straightforward way
1. Install material design icons-
$ yarn add #mdi/font -D
// OR
$ npm install #mdi/font -D
2. Then import the library where you initialize the Vuetify.
// Ensure you are using css-loader
import '#mdi/font/css/materialdesignicons.css'
import Vue from 'vue'
import Vuetify from 'vuetify'
Vue.use(Vuetify, {
iconfont: 'mdi'
})
After following the above steps, you can use the icons in your template like this.
<v-btn icon><v-icon>mdi-filter-variant</v-icon></v-btn>
Recommended way
While working on a project, it's best practice to move icons in a separate file for re-usability purposes. Here is how you can do this-
1. Create a file icons.js under your src folder and put icons inside it in an Object key-value format like this-
icons.js
export const custom_icons = {
"filter_variant": "mdi-filter-variant",
"filter_remove": "mdi-filter-remove",
...
...
// other icons in same format
}
2. Import the custom icons in the file where you initialize the Vuetify-
// Ensure you are using css-loader
import '#mdi/font/css/materialdesignicons.css'
import Vue from 'vue'
import Vuetify from 'vuetify'
import { custom_icons } from "#/icons.js"
Vue.use(Vuetify, {
iconfont: 'mdi',
icons: custom_icons,
})
After following the above 2 steps, you can use icons in your template like this-
<v-btn icon><v-icon>$vuetify.icons.filter_variant</v-icon></v-btn>
This could be resolved by using mdi stylesheet as Material Design Icons aims to cover the gaps Google left with their set in Material icons library and allow a lot more community integration.
Live Demo :
Vue.use(Vuetify);
var vm = new Vue({
el: "#app"
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/vuetify#0.14.8/dist/vuetify.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.1.96/css/materialdesignicons.min.css" />
<link rel="stylesheet" href="https://unpkg.com/vuetify#0.14.8/dist/vuetify.min.css"/>
<div id="app">
<v-btn icon color="indigo">
<v-icon>star</v-icon>
</v-btn>
<v-btn icon color="dark">
<v-icon>mdi-filter-variant</v-icon>
</v-btn>
</div>
Related
Visit Next.js and notice the page request in the network tab. Preview shows not just the HTML but completely pre-styled page.
When we use Styled-Components and Material-UI they have exposed ServerStyleSheet which is used for serving the required styles for the first render within the HTML.
import { ServerStyleSheet } from 'styled-components'
import { ServerStyleSheets } from '#material-ui/core/styles'
How can we achieve same output when using react-bootstrap or custom css like test.css?
Do you care if its a test.css or React bootstrap - Instead why not just inline all critical stylesheets?
It might be worth trying out their experimental feature
Add experimental: { optimizeCss: true } to next.config.js
Install critters#0.0.7 as a dependency
Via How to inline CSS in the head tag of a NextJS project?
Add your style file on the the _app file, you can create this file inside the pages directory in nextjs
import { AppProps } from "next/app";
import 'bootstrap/dist/css/bootstrap.min.css';
import "../your_style.css";
function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
}
export default App;
for react-bootstrap , you need to add npm i react-bootstrap bootstrap
Nextjs allows you to display SSG/SSR pages and javascript-disabled
users will still be able to see your app but the layout will be messy
if you use react-bootstrap components to build your layout.
To use react-bootstrap at SSR:
Install :
npm i react-bootstrap bootstrap
Import bootstrap styles in your _app.js:
import 'bootstrap/dist/css/bootstrap.min.css';
You can then use your react-bootstrap components as you would do in reactjs:
import {Container, Row, Col} from 'react-bootstrap';
const Layout = () => (
<>
<Container fluid>
<Row>
<Col>
<p>Running on Next.js at SSR</p>
</Col>
</Row>
</Container>
</>
);
export default Layout;
use Tailwind css
https://tailwindcss.com/
We can simply use classes and it make everything super easy for you design
Im trying to use a primary button from bootstrap in my Angular module. But it seems to not work.
Heres what I've done so far.
npm install ngx-bootstrap --save
Added bootstrap module and imports.
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { ModalModule } from 'ngx-bootstrap/modal';
imports: [
BrowserModule,
BsDropdownModule.forRoot(),
TooltipModule.forRoot(),
ModalModule.forRoot(),...]
exports: [BsDropdownModule, TooltipModule, ModalModule]
Now in the Module I use this code for a button:
<button type="submit" class="btn btn-primary">Submit</button>
but the button is still the standard html button. Not a blue submit button. Did I forget any steps when importing bootstrap. In the node_modules structure I can find bootstrap in there with the necessary .js and .css files.
Thanks for help.
You don't need to import modules, instead you need to attach styles from bootstrap. import them in the styles.css file or configure in the styles section of the angular.json file
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
]
or your relative/absolute path
Looks like in your case bootstrap is just about styling. Pure CSS styling of your HTML elements. Ngx-bootstrap it is about Angular components(the way you are decomposing your application). It's just like regular bootstrap with a jquery for interactivity but in an Angular world.
To get just bootstrap styles in your application you need to run command:
npm install bootstrap
Then put these source files into angular-cli.json:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
]
And rebuild you project.
We have two options to import the CSS from Bootstrap that was installed from NPM. One by configuring in angular.json and second by importing directly in src/style.css or src/style.scss. You can go through this https://loiane.com/2017/08/how-to-add-bootstrap-to-an-angular-cli-project/#3-importing-the-css and learn more about how to do that.
I want to use Fontawesome 5 Icons with VuetifyJs. Is that possible? which npm package for fontawesome should I use? because no one worked for me.
It is really confusing for me as an inexperienced VuetifyJs developer to use it, with the lack of any clear steps in the documentation of VuetifyJs.
From docs:
Font Awesome is also supported. Simply use the fa- prefixed icon name.
Please note that you still need to include the Font Awesome icons in
your project.
Release notes:
Things we added
v-icon now supports FontAwesome 5
You probably just need to include it in your index.html inside <head> or so
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
Then use like <v-icon>fa-search</v-icon>
To bring across my Vue specific answer, to get Font Awesome 5 working with Vuetify.js I needed the following setup in main.js:
import { library } from '#fortawesome/fontawesome-svg-core'
import { faCode } from '#fortawesome/pro-solid-svg-icons'
import { FontAwesomeIcon } from '#fortawesome/vue-fontawesome'
library.add(faCode)
Vue.component('font-awesome-icon', FontAwesomeIcon)
Then I use the imported icon on the template level:
<v-btn fab dark small color="black" v-on:click="addCodeBlock">
<font-awesome-icon :icon="['fas', 'code']"/> // <-- This replaces <v-icon>fa-code</v-icon>
</v-btn>
Install
yarn add --dev #fortawesome/fontawesome-free
// or
npm i --save-dev #fortawesome/fontawesome-free
Import
import Vue from 'vue'
import Vuetify from 'vuetify/lib'
import '#fortawesome/fontawesome-free/css/all.css'
Vue.use(Vuetify, {
iconfont: 'fa'
})
Use
<v-icon>fas fa-lock</v-icon>
What I want
Use the library HTML-GL inside a component in my Angular project (with the Ionic framework included).
What I got now
I included the library scripts inside my index.html, right above the polyfills.js - like this:
<!-- HtmlGL import -->
<script async src="assets/js/htmlgl.js"></script>
<script async src="assets/js/htmlGL_pulse.js"></script>
Right now the following web element works in index.html:
<html-gl>
<h1>This is an animated header</h1>
<html-gl>
What goes wrong
When I place the html above in a separate component I get the following error:
Uncaught Error: Template parse errors:
'html-gl' is not a known element
How can I make sure the component is aware of the `html-gl> tag?
To use dom elements which are not in the Angular registry you have to import the custom elements schema from angular core and append it to the schemas of your NgModule.
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '#angular/core';.
Since I seem to keep having issues with disappearing elements in Polymer...
I have the following files:
pubspec.yaml:
name: photon
dependencies:
polymer:
git:
url: git://github.com/dart-lang/polymer-dart.git
ref: 1.0.0-rc.5
polymer_elements:
git:
url: git://github.com/dart-lang/polymer_elements.git
web_components: ^0.12.0
reflectable: ^0.3.0
transformers:
- web_components:
entry_points:
- web/index.html
- reflectable:
entry_points:
- web/index.dart
web/index.html:
<head>
<link rel="import" href="packages/polymer/polymer.html">
<link rel="import" href="packages/polymer_elements/paper_toolbar.html">
<link rel="import" href="photo_view.html">
</head>
<body>
<paper-toolbar>
<div class="title">Photon</div>
</paper-toolbar>
<photo-view url="abc123"></photo-view>
<script type="application/dart" src="index.dart"></script>
</body>
web/index.dart:
export 'package:polymer/init.dart';
web/photo_view.html:
<dom-module id="photo-view">
<template>
<p>Photo <span>{{url}}</span> goes here with filters
[<span>{{filters}}</span>]</p>
</template>
</dom-module>
web/photo_view.dart:
#HtmlImport('photo_view.html')
library photon.photo_view;
import 'package:polymer/polymer.dart';
import 'package:web_components/web_components.dart' show HtmlImport;
#PolymerRegister('photo-view')
class PhotoView extends PolymerElement {
PhotoView.created() : super.created();
#Property(notify: true)
String url;
}
Based on the documentation I have found for Polymer.dart 1.0, this should work. Only issue is, the photo-view simply doesn't appear. At all. All I see is the toolbar. Unlike the last time this happened, rearranging the elements in index.html doesn't do a thing. I have tried:
Importing photo_elements.dart from index.dart.
Rearranging various imports and nodes in index.html.
Explicitly adding <script type="application/dart" src="photo_view.dart"></script> to photo_view.html.
None of them do anything. I even tried deleting the build and packages directories and re-running pub get and pub build.
If I open up build/web/index.html, I can see that none of the registration code from photo_view.dart is added. In fact, nothing from photo_view.dart is present. Could this be part of the issue?
I changed index.dart to
import 'photo_view.dart';
import 'package:polymer_elements/paper_toolbar.dart';
export 'package:polymer/init.dart';
/// Silence analyzer [PhotoView], [PaperToolbar]
const _silence = 0;
And it worked.
The last two lines are only to prevent "unused import hints" from the Dart analyzer.
If you are using <link rel="import"> style imports in your html (instead of dart imports in your dart file) then you will need to change your reflectable transformer configuration a bit:
- reflectable:
entry_points:
- web/index.bootstrap.initialize.dart
This is because the index.dart file can't reach the dart files which appear inside the html imports. The bootstrapped file however does contain all the necessary imports.
In general though it is encouraged to use dart imports instead of html imports.