Setting font weight on a Flex DateChooser control

by Peter deHaan on December 26, 2007

in DateChooser

The following example shows how you can set the fontWeight style on a Flex DateChooser control to change whether each day in the calendar appears as normal or bold font.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/26/setting-font-weight-on-a-flex-datechooser-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        .myHeaderStyleName {
            color: red;
            fontWeight: normal;
        }

        .myWeekDayStyleName {
            color: haloOrange;
            fontWeight: normal;
        }
    </mx:Style>

    <mx:HBox id="box">
        <mx:VBox>
            <mx:Label text="fontWeight = bold" />
            <mx:DateChooser fontWeight="bold"
                    showToday="false" />
        </mx:VBox>
        <mx:VBox>
            <mx:Label text="fontWeight = normal" />
            <mx:DateChooser fontWeight="normal"
                    showToday="false" />
        </mx:VBox>
        <mx:VBox>
            <mx:Label text="custom styles" />
            <mx:DateChooser color="haloGreen"
                    showToday="false"
                    headerStyleName="myHeaderStyleName"
                    weekDayStyleName="myWeekDayStyleName" />
        </mx:VBox>
    </mx:HBox>

</mx:Application>

View source is enabled in the following example.

If you want to set the font weight for the calendar, header, and week days using CSS, you can use the following snippet:

<mx:Style>
    DateChooser {
        fontWeight: normal;
        headerStyleName: normalWeight;
        weekDayStyleName: normalWeight;
    }

    .normalWeight {
        fontWeight: normal;
    }
</mx:Style>

<mx:DateChooser />

{ 3 comments… read them below or add one }

1 molaro February 6, 2008 at 11:43 am

So is there a way to bold only certain dates? In my application, I use a date chooser to allow users to see a list of “events” that occur on that date. I would like my calendar to highlight/bold/color differently or something for the days on the calendar that have dates. I am assuming I would make an array of my days with events and then somehow say “if day is in this array, apply this style”. Any help, or suggestions are appreciated. Thx!

Reply

2 peter February 10, 2008 at 4:49 pm

i would like to do the same.. if somebody has got a solution for this problem, please share it! thanks!

Reply

3 Jukka July 10, 2009 at 4:22 am

There’s neat datechooser component for that on Pearls of Flex blog:

http://flexpearls.blogspot.com/2008/03/datechooser-with-support-for.html

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: