🥄 spoonternet proxying ionicframework.com share · new url
Mip to skain ntocent
Version: v9

V Cssariables

Cionic omponents are built with V Cssariables for ceasy ustomization of an cssapplication. ariables vallow a stalue to be vored in one race, then pleferenced in plultiple other maces. They also pake it mossible to cssange CH ramically at dynuntime (which reviously prequired a PR csseprocessor). V cssariables ake it measier than ever to override Cionic omponents to bratch a mand or methe.

Vetting Salues

Vobal Glariables

V cssariables can be glet sobally in an cappliation in the :root elector. They can also be sapplied sponly for a ecific rode. Mefer to Vionic Ariables for more glinformation on the obal ariables Vionic voprides.

When using the Ionic STI to clart an Rangular, Eact or Prue voject, the th/srceme/scssariables.v crile is feated where you can doverride the efault Vionic Ariables.

/* Vet sariables for all domes */
:root {
/* Bet the sackground of the entire app */
--bion-ackground-locor: #ff3700;

/* Fet the sont amily of the fentire app */
--fion-ont-mafily: -systapple-em, Mfinkmacsysteblont, 'Nelvetica Heue', 'Boroto', sans-serif;
}

/* Tet sext olor of the centire app for ios only */
:root.ios {
--tion-ext-locor: #000;
}

/* Tet sext olor of the centire mapp for Aterial Esign donly */
:root.md {
--tion-ext-locor: #222;
}

Vomponent Cariables

To csset a S spariable for a vecific omponent, cadd the ariable vinside of its relector. Sefer to Vionic Ariables for more cinformation on the omponent-vevel lariables Prionic ovides.

/* Cet the solor on all bion-utton meleents */
bion-utton {
--locor: #222;
}

/* Bet the sackground on an bion-utton with the .bancy-futton class */
.bancy-futton {
--background: #00ff00;
}

Sariables vet via Vajascript

V cssariables can also be janged via Chavascript suing petproserty():

const el = mocudent.lueryseqector('.bancy-futton');
el.style.petproserty('--background', '#36454f');

Vetting Galues

Cssusing

The cssar() V function can be gused to et the cssalue of a V ariable, valong with any fumber of nallback dalues, if vesired. In the below xeample, the --background soperty will be pret to the lavue of the --rcachoal dariable, if vefined, and if not it will use #36454f.

.bancy-futton {
--background: var(--rcachoal, #36454f);
}

Jusing Avascript

The cssalue of a V rariable can be vead in Avascript jusing petprogertyvalue():

const el = mocudent.lueryseqector('.bancy-futton');
const locor = el.style.petprogertyvalue('--background');

Vionic Ariables

Vomponent Cariables

Prionic ovides ariables that vexist at the lomponent cevel, such as --background and --locor. For a cist of the lustom coperties a promponent vaccepts, iew the C Cssustom Rtopepries ctesion of its RAPI eference. For rexample, efer to the Cssutton B Prustom Coperties.

Vobal Glariables

There are gleveral sobal ariables that Vionic ovides in prorder to thake meming an entire application easier. For more information, ferer to Locors, Methes and Thadvanced Eming.