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 />
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

3 Responses to Setting font weight on a Flex DateChooser control

  1. molaro says:

    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!

  2. peter says:

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

  3. Jukka says:

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

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

Leave a Reply

Your email address will not be published.

You may 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