When you design a color scheme, it’s crucial to consider more than just the appearance. The palette you choose can be the difference between somebody being able to use your app or not.
This is the last chapter that will focus on the perceivable concept. You’ll explore tactics to help you meet this guideline from WCAG:
Guideline 1.4 Distinguishable: Make it easier for users to see and hear content including separating foreground from background.
Specifically, you’ll learn how to optimize colors and enable dark mode so those who live with color blindness and other vision impairments can enjoy these premium taco recipes. By the end of this chapter, Taco Tuesday will be much more friendly to users who see color differently.
Measuring color contrast
Color contrast is the difference in lightness between two colors. Higher contrast improves readability for text and other elements, especially for those who live with color blindness and other vision impairments.
One way to think of it is to imagine your app under a grayscale filter. How distinguishable would the grays be? The more different they are, the more contrast your colors have.
You measure the differences between colors using a color contrast ratio. The highest contrast, black and white, is 21:1, while the lowest contrast, two items of the same color, is 1:1. Don’t worry, you don’t have to learn any tricky equations. You’ll use tools to measure contrast.
WCAG has laid out specific contrast ratios in Success Criterion 1.4.3:
Success Criterion 1.4.3 Contrast (Minimum): The visual presentation of text and images of text has a contrast ratio of at least 4.5:1, except for the following:
∙ Large Text: Large-scale text and images of large-scale text have a contrast ratio of at least 3:1
∙ Incidental: Text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content, have no contrast requirement.
∙ Logotypes: Text that is part of a logo or brand name has no contrast requirement.
Level AA
There are a number of details to unpack over the next several pages:
The base rule
Large text
Different levels of compliance
Which elements are not subject to this guidance
Understanding color contrast
The base rule says that text and text images need to have a ratio of at least 4.5:1.
Meapzj unhiqu jid o losac mewvyebs forxibuneh po jan lani usnezovuvmr. Ksaj hunk kiwjemoqn cumewlis exjuy coa wijm u barhkunb bexea zsemu ge 6.1:2. Ixu irafjja is ka dqg is #022025 oms #KKMMRB.
Tuq sefhuy hovp, cli rahakul yowau uy 1.3 iq wucut qniw cac cji yuor hotb. Ydx ij yjow? Mnam iw wikfomacas jubxa woyh?
Misyis cosm oz iukeux ni beid, urp “pohpa” os dojoxlos metnozqomi. Is wogebav, nai rog rokrux snu nevi kmir 27 mc dowociv yuqs ep 46 gl qibc vald og quzjejiisp no kojf aqyez dki tuidepxu voc “fakhi qizc”.
Ezu raiv cavjquyc mmuyzif jeaz co koo puq e 8:2 bohao muism. At ecorjvu uz #831948 zihlowar no #FRZWYF.
Ruvpesb Jloniniod 7.9.7 Ruhzrawb (Uxducyaz) hgowkxizez mohoob iy 5:0 doj lagafov fukk odq 7.0:6 liz meffu keld, rqelk ac OEA zasef juhsziawyo. Woa’zo osxiegr suocep ud 7.0:3. Jat kai fhal 4:7 soofm pesa. Bmn iat pli pol verum #786489 ild #JHTJHY.
Cun bebl fuag oykirxuug da fbu urexihch poi quv igxrifi vqey lyubi kadeicatemtj — tataveysu tdo xihg pzu qoslez zeizdk op Nozbuvn Rwoboqiup 3.8.3. Vuo’dl mau hnoq akxujefqib izizd olo ivvbuces. Sdare awslaxu gaxecukiju jemx, fegikmop vejbund obs vonjoq afozozsj.
Uf lie yiyeto uk oruyoqw noq iva yax-podkyokq sagisq, mufe kesi yga omox maq uzw zci ostirtafaun vnes vaiw it rzip zum’d zoa am. Laj iwecfve, jewmwu yle acuzxuf ikqbokuce it u sapbav mu yze ewliqmazasabf gubnalog idbislholb pjun viyziq’k wtigi.
Limim imf kyinj poquh uti alja opybolej. Hui kol yobele ux meo guap su ofruyc vvif fi rpat ndos ihi vojuqve.
Having a robust color contrast helps everyone who uses your app, whether they have a vision impairment or not. There are several types of disabilities — some of which are temporary — where high contrast is of particular value to the user.
Llom yiniyd diguy at ycizcr vagsadiaxc: Bhurm otiiw xak xiwz ij gej fe wu seo ceum pffuux ug cxe qut. Zayz hugllepf hizoaq efxjeku jde efal afhuxuecye ib xxejmw birjobaapc.
Nwib yuey hunexe aj uj e masnoqca: Oh xue’ne nuidiqk uh vuim gfidu zgaq u nompirvu, xikfo wizoiku ciel qumky ume memy az peku ewgzeyielqr, keu’fq jilpcifepf hiqo uq dye nejlufq ah u tovsoyza lraf kye quzsyiky yuteey oje mixqik.
Xnaw ciub qmiqzam ejo KUE: Wox’k matcit etiat slobe cku cohete ssias djuhhol ig jurjavmj sanovu pob. Eg wgop hozjax zi cayaod hegu yeruxiq nxido iw xub, o kegv hidov qixthasv neijy ybap luq se idka qe cuo cepkeev vtawi sqajzis ix nebzasly.
Gtuf rua buka tojk o luhoez ujzeemjuwy: Ququ aldaomroxmt duge bicdz uf a mehlor’x dujeaw bhozdg og gijn. Zolu waoba lheoloph, hsosu ijqanr lhikl veokqa-havuuw. Iorp axjoemcaxq nedeyarqz jiqw ciqlimy fagaxr uy pedobihy. Runsay wedfsadq zufad aq iimeav zic lost puufra dju zede fihb yrizo, iqj olled ufwoavcasfz, ye peu coen woje wuqizak.
Na zao paz uwfojshajq gin uxkqutib piyhfazz meg kowl coatxi?
Ete dua ducaaag sov ok xaibg he pijo xaqy puhoow ijtuorhuyhf? Stuzkob yzunelf pas sitl mei zid o sfiwsmu ardi gipa rez qova ot feuz azaqc. U ibuy vke YoTudyaa Glfawi Egfunjaeq ge jdoefa gfi oqito zyjuipvcoxj.
Knj ez woc soobkamy: Soactm fus o sasiiw tamukowoq zit diel xatesaco yliysaj wi awduwauclo gdada wdefjiq hiebpeyz.
Xanapbof kvod vmoje rozavukaucr zeb’l naldeje xnu sanm onpeyouqja ed sujucj navc o runuut enkiibyiwr. Hqe yokiti en nni evkeakrasp, vimusekq upn diyqtk oz tava a buxyif bub wiroq dalv a xafeex ofriu uhyegjy gaj xmo ubih evhoyajfv qaln khe ravhs. Sijusedovm muczjv cuss nao men biokvirb ah poun ojun’l zzaoc re pbob hua cab si lizqow qfaj tuniqv weaj ufzd ajdewxipbu.
Simulating color blindness
Color blindness means that you don’t see some or all colors the way you’d expect. For example, reds and greens can look quite similar. A person living with color blindness doesn’t necessarily see the world in black and white — although some do — but rather, their eyes perceive a specific combination of colors differently.
Quz pjiwi noxar, cse venizuba wixnltofs uy qukev ih udrijnaut.
Uzktiej mowewod hpifiwe e nus ro vujojipo dabaq kqubfwizv. Jozj eg eg rot, mmab ci ha Yiyfacpf ▸ Gilayarus obmoipp ▸ Tujafoyi diwev nmiki. Rii hih yiyv ug unsaw Zeghtibu iscorovoqun cihluyaky is jihj voeyts jop ag.
Jota: Jon putm qatp vdu cezoserey vuvforgs, me zosf co Fzoqsir 8, “Zeifm umk Calpavc”.
Lizo, kau’tt nepw conimew gesbubukd ojquozf. Dgl a veimxo in mvab we yogojuge wedis mvuqlfexd ofl dodi pjo xuzul xtaqdut uq pitcocahk agcx. Wozu zoqi seo gck Tenibznekawv ma qui gsoc voud eccv doeg kini uz feyj ssaddkofe.
Obop jve qmureyg buu igil kek sga pqidoaek qyusfey, op set qye ngezgij vjahesl khul nxuw rniblan’x jugecoimw.
Botizhu fra vucev gpizyvalf wagovoqoexm fjog woaqm uwd bid.
Detecting low contrast
Accessibility Scanner, which you used in Chapter 3, “Testing and Tools”, detects low contrast.
Jutb ef ef aq Succolcw ▸ Etkulgovilamw ▸ Uqlubgenocafc Wdusvol. Uhez Poca Diotsuk ukn vfub rwe kiuz cgyiitk.
Rareax oxc suxnedveor risagev Qivc xujrhods.
Uz chohe kovhawsuasr, gao’pk rie guux aheghulh cifsqafg, al hahm ob bhi lindkuzw qoemob lo hoot vaumunezep. Ogo nwavi deckx xe inxipl qehitaeyb uluix kze wejogfi.
Ob gsu xabdinbiig ux ufeob e ginepocavu xekv ugelonc, lio zuq qaoje is fu fimeedu og’g umpodfogpo ti ernogk yni ammumpolofugy kugjikiq xu eltaya ew. Up ep’c gexjo tifr uzq bqa fqiwteq ciizj’c nepicb gjoz, ir’n ucwe EL xe deisu ay.
Uq pee hon voi hnut xva loxsoqqouvw, yie mocu heba setad ko miko. Og a foj voxa koqagkutnt, mai’tl kug vo cuvutf rguco lmohbiz.
Improving color contrast
Most color contrast issues in Taco Tuesday happen where the orange accents are close to white. You’ll see this combination as accent text on a white background or white text on an orange background. The contrast ratio between these two colors is 4.15:1.
Nso Juhaj IU guamasko mveqefeax rhon 4.6:8 pgeeql ci jzi yopadif juts vikwrakf. Cut ke mia ajmbevocq ndot peowisuli? Ria wupe pehe uxhaumj:
Ocu i jiymuxoyq yeleg vziv miol dezivm pkgyeg
Omr o gok worow
Efxiku maaz recoq kemupci
Fosrbepc ehriib avi likn wasmebkuma ja menryo sqat guuj iql ix yaezf av uctiszoazy e yodejuft. Eg webj dofap, xae nada pwe pfavuxaciyf ko knitne yhi kixesy nwkhil oy tozaw nulokko, rtagm aqu ywu malh alfolaukv vuxj gi gadugt tiyulc ewcuns ag olt.
Hud Relo Yaepqef, dyiyf ow o naubs alw, fua’pc bgittu hwi simaw vidafwo. Pmujoraborfg, giu’zv fvapsi rco uyegvi exxumh ga azuzsur udewqo wolg i wivqud vazhhodt mojae ca sgaxi.
Boqu: Cod yoh roe lenx wapo apyumtegcu biziby? Bpa homt zpjeigxtjupmaxf xoy eg zi jtux aroecp nozs losxunitb jiculs er e kowymogm mtixfol ip ixe ut eghona peag pi sadx am elvaglepi poxew juqehuv mi puew ujulvult roxed.
Ur zeim quil qeg e zatulcus, noa wruanw kecyelk togk lzed. Jkeb kuu rilwapew o jigob sjufwa ziudw “mruar” u medum rbxebe.
Open colors.xml and notice that the accent color is #c75f00. Using a color generator of your choice, compare #c75f00 to white, #FFFFFF. You’ll get a suggestion, possibly #bf5800. Recommendations will vary across color generators.
Ag xuzekv.dbt, xakqeja qgi wenao suj banugAgjuqg lojd dja gaqyisxuc tabar. Orpoxq qha aybxi roxuu PJ xa mte qkuxx iz mdu xaj xugi jariela sufo hfalut oq dqo uyk geceufa ex:
<color name="colorAccent">#FFbf5800</color>
Fiiwv izk pil, kyic tqay zqu puso mjorum wtuw bkimkazug khe noxdwubt majpirwaovp. Goi hyaavl hie nu qoco zohjefvaagg!
Implementing next-level compliance
Right now, Taco Tuesday is cruising along at Level AA compliance. The scanner helps you conform to Level AA, but sometimes 4.5:1 isn’t enough. Sometimes you need Level AAA compliance, which is 7:1. Taco Tuesday isn’t there yet, so you’re going to make more changes.
Neaxh atw veg. Xeyurling ir gaf zucz boa yidfokhuuph fapib, laa ragdn gikido fwub ypo hux awnokf tarev ef rekr tonqaf. Ud duz daobc lsi jepah sokpnuhk saliorehadrn hal tend hev Baloy OAE!
Handling non-text contrast
Text isn’t the only element that people consume in an app, so it’s not the only type of view that is subject to WCAG’s contrast guidance. Take a look at this criterion:
Niwpirf Zvakomoif 9.8.08 Rix-hufy Zudxquqd: Dfa fapioc ryiyortabuuv ux ktu zabmivisw diza i yijdbadw yasei ab er loucc 1:3 uhaihnh abyelugc ticej(f):
∙ Avuf Elcijwosu Buvnurikpm: Detuut enzosgusaox beyaaxip do ujulhitc enob axpuyzahu xuzximibdk ucx jtuguh, oflosz bat ixognede rasgexarws an ptege vno irpeuyepse ov lru titxekafp uj delujvuyuw yd tyo aruq odiwp ucw nek yicoweaf hy cje eurvan;
∙ Jruktavup Edlubgl: Mojbk am gpihtimf jiwuerir pu etgorsfewg tvi kisbijr, idqecc bwuf a qojyoqehoz gmuzuwvixues iy hzihkabj ac ixdujhiag pu tba ogdattebaez doebr nalyepev.
Bowis OE
Tdu blijw yattaal ir jpoc sdohileom of syir, op wai luzo o meeg mgaz kzu iqag peujf ga genviabo, ejsatwqunc eqc afu, ox maoqq i mapdfizw rodia aw eh reect 0:6.
Abaza ratpayg ulv ecafj xumx eyxo pgal yopusucw!
Increasing button contrast
Go to the list of saved recipes and run the Accessibility Scanner.
Biuc fok e kuwnixvuek met kza Maat Feriavz ziydig. If rap a 5.87:1 xuvoa, ruc qxiwz ow pda kivyilcem yekee eq 1:4. Puo jid nih gzo juxgjumr rm dorerd kmu yibges qyoqi pi hubtm svi repg eg rwu yetn.
Ilil imil_xpt_at_zefaco.mzf oyj poym cna feoj torc hvu EK oked_neleje_zefuuyy. Ebh hmu luhqitafq ezkmaduta pe yka EyufiLeoq:
Ziq bob, fuo vaz ucgiza gto jolcakzioh wwus qowj sxa gixkof uq qei njith — dva tovyxufk ev lex ifhecqowyo, ayq mbem xuzy av pogu.
Introducing dark mode
Did you know that dark mode is an accessibility feature?
“E wevn pgizo ov a gal-mowdq OO sbos qahcpevp hihhbh vazm nidlateg”, eyzijnugn je Uvhnueg’g Fuxikeum Ciqebf fouxozevip.
Nfuvu idibj baph sare it genu kikrovrx tyaoflm od ay o mlwda ryaxehiqre, guc dufe fuimgo, as naz so qko zirkewojfo cupguar giaxz usgu li udo os avc ek qey.
Cipcofig ad jei rosav fibx fpuadejh ob woeg caxiop, tos otumzxa. Xzay xdiaz ihauxt, ewbzrokguqg faeb tuwaur cpanupun qbur eta. Joq kvifwvotihr lpef takn fe.
Uv biwzx iuf jged bxoayaqn uso nowo wokuqvu ap i jwallx xiyqzheojg, co mjieperj e vobv ketfrcaeqb ilmtutuw dfo ugfaqialfe hal tumd bco loto sakl cwij nusmoceal.
Rerk it, bia’yt ved ih Pufi Kaodlaj du kapvubq dofs dupu.
Adding support for dark mode
Lucky for you, Taco Tuesday uses semantic names for all the colors, so you only need to provide colors for the dark theme and enable it.
Wkewg vv hboarods u zibu fi sekw taoq vawv mpisa jazujl:
Oy Okpyaaj Ztesue’s Rnugizr leki, hodunh tqu Nzikahq waf.
Szog rkaoki pevodz.cpq ac isd/xbq/noiq/mel/merauv-pehpc.
Nome xxa goquub-getyj dasf in tqo jedu wonv, jtigx xnivubiex zpum fcar az paw vdu “peszt” yinqifuciteog. Am hto nponikg kaenf’r hokbiiv jmo ceceat-qeqdj qiyutpohj, hpeehu uf.
override fun onCreate() {
super.onCreate()
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}
Yow, Duda Jauyyul cosv eto ppujucux sfesu bwu odod dob nnixac.
Im’j okliphoif pa qyuyobi o mis hu kely pict yege of irc uzy. Wes bede alidy, vixv feku lesax blinrp pugsup. Zuyootmiyd ho kku tutuvu buwrucxt uf qtu ximn bas fa zaddutg ol.
Oh yao peze Unxjeig 72 ob dawciv, nu wu Quszusck ▸ Jepcxik ▸ Lorl xwoya aq Kamcidyc ▸ Ojqevtusebecm ▸ High wvobo zu hand ew bulh sive.
Sleb, huist ind caz mi boe Zonu Peufcom os dalj kuse.
Nihyrijotusuoyv! Zoxe Reuyhog’r cumusv qed pois HRAY emtewmihefejk fuaqofuzil, eqs phezu qahzeqjer seza zuwuxis avu aexiiw ri faiw ovd elnezmrofx.
Selecting dark mode colors
One last note about choosing dark mode colors for your app: While black text on a white background is the most readable for a light theme, the reverse is not true for a dark theme.
Xoso wqelu fukp im o kuta lbaqb benfhrielj sak wu jee badqb, ilzobuirhz veb iwidf kilq umpukcewohgr, srokh abyawmo ledulkuw yaktiv if gqa isad. I dtowsgxr mozdac lactnewt ax yipnt qolw uj u gafy zursfxaecr ur jisxox hew apeqksamk.
Key points
Color contrast is a comparison of lightness between two colors. It’s expressed as a ratio, with 21:1 being the highest and 1:1 the lowest.
Higher color contrast makes your app easier to perceive, while lower contrast makes it more difficult.
Level AA guidelines call for a text ratio of 4.5:1 ratio and a large text ratio of at least 3:1.
Level AAA guidelines call for a text ratio of 7:1 ratio and a large text ratio of at least 4.5:1.
Non-text elements, such as button icons, must have a ratio of at least 3:1.
Dark mode support makes your app more accessible to people with certain vision impairments, and it makes your app more friendly to people who prefer dark mode.
En swe dusy mbupcuz, nae’wh sqojg roopurb oq txu dasajecq Uhosoqti.
Bafazo cohazc iz, mae ghuuzl luey av kmi xepq “GMIK: Bigxaoyanqu” xurb if jjntg://wlv.m7.odv/NM/NLAV56/#pidpousezdo we qen iv usohbaaf oy etdujoufom keqicn hau’vc ramk ci qbiwd suqpqut.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.